Description Usage Arguments Value Examples
Perorm a survey bootstrap
1 | survey_bootstrap(design, fun, ...)
|
design |
an object of class svydesign |
fun |
a function taking a dataframe as a parameter |
... |
additional parameters passed to as.srvrepdesign |
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.
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.