[R] svyglm and sandwich estimator of variance

Roberta Pereira Niquini robertaniquini at ensp.fiocruz.br
Fri Dec 19 13:56:07 CET 2008


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? 

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



More information about the R-help mailing list