Learn R Programming

surveybootstrap (version 0.0.3)

rescaled.bootstrap.weights: rescaled.bootstrap.weights

Description

This function creates a dataset with rescaled bootstrap weights; it can be a helpful alternative to bootstrap.estimates in some situations

Usage

rescaled.bootstrap.weights(
  survey.data,
  survey.design,
  num.reps,
  weights = NULL,
  idvar,
  verbose = TRUE,
  parallel = FALSE,
  paropts = NULL
)

Value

if no summary.fn is specified, then return the list of estimates produced by estimator.fn; if summary.fn is specified, then return its output

Arguments

survey.data

The dataset to use

survey.design

A formula describing the design of the survey (see Details in bootstrap.estimates() help page)

num.reps

the number of bootstrap replication samples to draw

weights

weights to use in estimation (or NULL, if none)

idvar

the name of the column in survey.data that has the respondent id

verbose

if TRUE, produce lots of feedback about what is going on

parallel

if TRUE, use the plyr library's .parallel argument to produce bootstrap resamples and estimates in parallel

paropts

if not NULL, additional arguments to pass along to the parallelization routine

Details

The formula describing the survey design should have the form ~ psu_v1 + psu_v2 + ... + strata(strata_v1 + strata_v2 + ...), where psu_v1, ... are the variables identifying primary sampling units (PSUs) and strata_v1, ... identify the strata

Examples

Run this code

survey <- MU284.complex.surveys[[1]]
rescaled.bootstrap.weights(survey.data = survey,
                          survey.design = ~ CL,
                          weights='sample_weight',
                          idvar='LABEL',
                          num.reps = 2)


if (FALSE) {
bootweights <- rescaled.bootstrap.weights(
                                         # formula describing survey design:
                                         # psu and strata
                                         survey.design = ~ psu +
                                                           stratum(stratum_analysis),
                                         num.reps=10000,
                                         # column with respondent ids
                                         idvar='caseid',
                                         # column with sampling weight
                                         weights='wwgt',
                                         # survey dataset
                                         survey.data=mw.ego)

}

Run the code above in your browser using DataLab