André Grow
2017-Feb-08 19:43 UTC
[R] Does "coeftest" correctly use weights from "svydesign" in "svyglm" object?
Dear all, I am using data from the European Social Survey (ESS) and I would like to calculate country-level cluster-robust standard errors for a regression model in R that includes country fixed effects and employs the design weights that come with the ESS. To correctly use the weights, I use the 'survey' package and the functions 'svydesign' and 'svyglm'. This step looks like this: design_1 <- svydesign(id=~1, weights=~dweight, data=ESS) m1 <- svyglm(y ~ cntry + x, design = design_1) My question is: when I now apply the functions 'cluster.vcov' and 'coeftest' from the packages 'lmtest' and 'multiwayvcov' to the model m1, do the resulting standard errors correctly account for the design weights? This step looks like this: vcov_m1 <- cluster.vcov(m1, ESS$cntry) coeftest(m1, vcov_m1) Note that I do not use 'cntry' as an id variable in the svydesign function, because then I cannot include country dummies in the regression model. Thanks in advance for your feedback! [[alternative HTML version deleted]]
Anthony Damico
2017-Feb-09 07:36 UTC
[R] Does "coeftest" correctly use weights from "svydesign" in "svyglm" object?
hi, that setup is not correct. see examples in https://github.com/ajdamico/asdfree/tree/master/European%20Social%20Survey On Feb 8, 2017 11:54 PM, "Andr? Grow" <grow.andre at gmail.com> wrote:> Dear all, > > > > I am using data from the European Social Survey (ESS) and I would like to > calculate country-level cluster-robust standard errors for a regression > model in R that includes country fixed effects and employs the design > weights that come with the ESS. > > > > To correctly use the weights, I use the 'survey' package and the functions > 'svydesign' and 'svyglm'. This step looks like this: > > > > design_1 <- svydesign(id=~1, weights=~dweight, data=ESS) > > > > m1 <- svyglm(y ~ cntry + x, design = design_1) > > > > My question is: when I now apply the functions 'cluster.vcov' and > 'coeftest' > from the packages 'lmtest' and 'multiwayvcov' to the model m1, do the > resulting standard errors correctly account for the design weights? This > step looks like this: > > > > vcov_m1 <- cluster.vcov(m1, ESS$cntry) > > > > coeftest(m1, vcov_m1) > > > > Note that I do not use 'cntry' as an id variable in the svydesign function, > because then I cannot include country dummies in the regression model. > > > > Thanks in advance for your feedback! > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]