# NOT RUN {
data("cluster_sample")
data("psu_ssu")
## Calibrated two-stage cluster design
design <- DesignSurvey(na.omit(cluster_sample),
psu.ssu = psu_ssu,
psu.col = "census_tract_id",
ssu.col = "interview_id",
cal.col = "number_of_persons",
cal.N = 129445)
## Simple design
# If data in cluster_sample were from a simple design:
design <- DesignSurvey(na.omit(cluster_sample),
N = sum(psu_ssu$hh),
cal.N = 129445)
## Stratified design
# Simulate strata and assume that the data in cluster_design came
# from a stratified design
cluster_sample$strat <- sample(c("urban", "rural"),
nrow(cluster_sample),
prob = c(.95, .05),
replace = TRUE)
cluster_sample$strat_size <- round(sum(psu_ssu$hh) * .95)
cluster_sample$strat_size[cluster_sample$strat == "rural"] <-
round(sum(psu_ssu$hh) * .05)
design <- DesignSurvey(cluster_sample,
N = "strat_size",
strata = "strat",
cal.N = 129445)
# }
Run the code above in your browser using DataLab