Created
February 28, 2019 17:11
-
-
Save ajdamico/9b3232a1d986b3460baaa90f5fed3402 to your computer and use it in GitHub Desktop.
incorrect standard errors when not including the full design information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(survey) | |
data(api) | |
x <- apistrat | |
x <- subset( x , comp.imp == 'Yes' ) | |
dstrat_before<-svydesign(id=~1,strata=~stype, weights=~pw, data=x, fpc=~fpc) | |
dstrat_after<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc) | |
dstrat_after <- subset( dstrat_after , comp.imp == 'Yes' ) | |
SE( svymean( ~ api00 , dstrat_after ) ) | |
SE( svymean( ~ api00 , dstrat_before ) ) | |
@nstjhp dstrat_before
is incorrect. subsetting a complex sample must happen after svydesign
Thanks for swift reply @ajdamico !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
possibly a dumb question but which one is incorrect @ajdamico ?