# generate syntax for an independence model
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data=HolzingerSwineford1939)
# extract data slot and options
lavdata <- fit@Data
lavoptions <- lavInspect(fit, "options")
# create bootstrap sample
boot.idx <- sample(x = nobs(fit), size = nobs(fit), replace = TRUE)
newX <- list(lavdata@X[[1]][boot.idx,])
# generate update lavdata object
newdata <- lav_data_update(lavdata = lavdata, newX = newX,
lavoptions = lavoptions)
Run the code above in your browser using DataLab