library(survey)
data(api)
dstrata <- apistrat %>%
as_survey_design(strata = stype, weights = pw)
dstrata %>%
summarise(api99_var = survey_var(api99),
api99_sd = survey_sd(api99))
dstrata %>%
group_by(awards) %>%
summarise(api00_var = survey_var(api00),
api00_sd = survey_sd(api00))
# standard deviation and variance of the population variance estimator
# are available with vartype argument
# (but not for the population standard deviation estimator)
dstrata %>%
summarise(api99_variance = survey_var(api99, vartype = c("se", "var")))
Run the code above in your browser using DataLab