data-raw/bootImputeAnalyseExamples.R

library(mice)

set.seed(564764)

#bootstrap twice and impute each twice
#in practice you should bootstrap many more times, e.g. at least 200
imps <- bootMice(linquad, nBoot=2, nImp=2)

#analyse estimates
#write a wapper to analyse an imputed dataset
analyseImp <- function(inputData) {
  coef(lm(y~z+x+I(x^2),data=inputData))
}
ests <- bootImputeAnalyse(imps, analyseImp)
jwb133/bootmi documentation built on June 9, 2025, 4:58 p.m.