survey_bootstrap: Perorm a survey bootstrap

Description Usage Arguments Value Examples

Description

Perorm a survey bootstrap

Usage

1
survey_bootstrap(design, fun, ...)

Arguments

design

an object of class svydesign

fun

a function taking a dataframe as a parameter

...

additional parameters passed to as.srvrepdesign

Value

a list with class boot_est containing 'value': the value of the function applied to dat. 'var': the boostrap variance. 'replicates': The bootstrap values of fun. 'nrep': the number of replicates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(survey)
data(api,package="survey")
## one-stage cluster sample
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
## convert to JK1 jackknife
rclus1<-as.svrepdesign(dclus1)
## convert to bootstrap
set.seed(1)
bclus1<-as.svrepdesign(dclus1,type="bootstrap", replicates=100)
attr(svymean(~api00, bclus1),"var")
set.seed(1)
survey_bootstrap(dclus1, fun=function(dat, wts) {sum(wts*dat$api00) / sum(wts)},
  type="bootstrap", replicates=100)$var

ifellows/TestingHistoryIncidence documentation built on May 30, 2019, 8:04 p.m.