Created
February 18, 2021 19:20
-
-
Save bschneidr/a5db85900f814d7632989524050f59ac to your computer and use it in GitHub Desktop.
Survey Package TSL Covariances between Subgroup Estimates
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) | |
# Get example data | |
data(api) | |
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) | |
# Estimate means by subpopulation | |
# Use `covmat = TRUE` to also estimate covariances | |
mns <- svyby(~api99, ~stype, | |
dclus1, | |
svymean, | |
covmat=TRUE) | |
# View variance covariance estimates | |
vcov(mns) | |
# Estimate contrast | |
svycontrast(mns, c(E = 1, M = -1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment