# example using a simple random sample
survey <- MU284.surveys[[1]]
estimator <- function(survey.data, weights) {
plyr::summarise(survey.data,
T82.hat = sum(S82 * weights))
}
ex.mu284 <- bootstrap.estimates(
survey.design = ~1,
num.reps = 10,
estimator.fn = estimator,
weights='sample_weight',
bootstrap.fn = 'srs.bootstrap.sample',
survey.data=survey)
if (FALSE) {
idu.est <- bootstrap.estimates(
## this describes the sampling design of the
## survey; here, the PSUs are given by the
## variable cluster, and the strata are given
## by the variable region
survey.design = ~ cluster + strata(region),
## the number of bootstrap resamples to obtain
num.reps=1000,
## this is the name of the function
## we want to use to produce an estimate
## from each bootstrapped dataset
estimator.fn="our.estimator",
## these are the sampling weights
weights="indweight",
## this is the name of the type of bootstrap
## we wish to use
bootstrap.fn="rescaled.bootstrap.sample",
## our dataset
survey.data=example.survey,
## other parameters we need to pass
## to the estimator function
d.hat.vals=d.hat,
total.popn.size=tot.pop.size,
y.vals="clients",
missing="complete.obs")
}
Run the code above in your browser using DataLab