Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.64.0812221633020.5556@homer21.u.washington.edu>
Date: 2008-12-23T00:36:55Z
From: Thomas Lumley
Subject: svyglm  and  sandwich estimator of variance
In-Reply-To: <20081219125030.M42392@ensp.fiocruz.br>

On Fri, 19 Dec 2008, Roberta Pereira Niquini wrote:

> Hi,
>
> I would like to estimate coefficients using poisson regression and then get
> standard errors that are adjusted for heteroskedasticity, using a complex
> sample survey data. Then I will calculate prevalence ratio and confidence
> intervals.
> Can sandwich estimator of variance be used when observations aren?t
> independent? In my case, observations are independent across groups
> (clusters), but not necessarily within groups.  Can I calculate the standard
> errors with robust variance, in complex sample survey data using R?

The standard errors that svyglm() produces are already the sandwich 
estimator and already correctly handle the clustering.

Use vcov() to extract the variance-covariance matrix, if you need it, or 
SE() to extract the standard errors.

 	-thomas



> Outputs:
>
> design_tarv<-svydesign(ids=~X2, strata=~X3, data=banco, weights=~X4)
>
> banco.glm7 <- svyglm(y ~x1, data = banco,  family = poisson (link= "log"),
> design= design_tarv)
> summary(banco.glm7)
>
> Call:
> svyglm(y ~ x1, data = banco, family = poisson(link = "log"),
>    design = design_tarv)
>
> Survey design:
> svydesign(ids = ~X2, strata = ~X3, data = banco,
>    weights = ~X4)
>
> Coefficients:
>            Estimate Std. Error t value Pr(>|t|)
> (Intercept) -0.91893    0.04696 -19.570  < 2e-16 ***
> x1              0.19710    0.06568   3.001  0.00603 **
> ---
> Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
> (Dispersion parameter for poisson family taken to be 0.5722583)
>
> Number of Fisher Scoring iterations: 5
>
>
> library(sandwich)
>
> vcovHC(banco.glm7)
>                 (Intercept)                    x1
> (Intercept)  4.806945e-13              -4.771409e-13
> x1             -4.771409e-13            7.127168e-13
>
> sqrt(diag(vcovHC(banco.glm7, type="HC0")))
> (Intercept)           x1
> 6.923295e-07    8.426314e-07
>
> # I think this result isn?t correct, because standard errors are so small.
>
>
> Thank you for the help,
> Roberta Niquini.
>
>
>
>
>
>
>
> --
> ENSP - Fiocruz
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle