library(surveysd)
library(data.table)
setDTthreads(1)
set.seed(1234)
eusilc <- demo.eusilc(n = 3, prettyNames = TRUE)
## draw replicates with stratification
dat_boot <- draw.bootstrap(eusilc[year<2012], REP = 3, weights = "pWeight",
strata = "region", hid = "hid",
period = "year")
## get selection matrix for year 2011
dat_selection <- get.selection(dat_boot[year==2011])
print(dat_selection)
## draw bootstrap replicates for year 2012
## respecting already selected units for year 2011 ~ dat_selection
## in order to mimic rotating panel design
dat_boot_2012 <- draw.bootstrap(eusilc[year==2012], REP = 3, weights = "pWeight",
strata = "region", hid = "hid",
period = "year",
already.selected = dat_selection)
Run the code above in your browser using DataLab