I would like to bootstrap a multilevel sem model including indirect relationships, however when I include the bootstrap argument I get the following error:
FactorA <- sem(model1, data = Daily_Diary_Study_WERKDOC_parcels_CMC_2,
+ cluster = "id",
+ estimator = "ML",
+ se = "bootstrap", bootstrap = 10000, fixed.x = FALSE)
Error in lav_options_set(opt) :
lavaan ERROR: `se' argument must one of "none", "standard" or "robust.huber.white" in the multilevel case
Is it even possible to bootstrap a multilevel sem model in R? Or merely the indirect relationships I aim to test within this model would also do.
Thank you!
I tried this:
FactorA <- sem(model1, data = Daily_Diary_Study_WERKDOC_parcels_CMC_2,
+ cluster = "id",
+ estimator = "ML",
+ se = "bootstrap", bootstrap = 10000, fixed.x = FALSE)
And I expect bootstrapped confidence intervals for my estimates
Yes, but what kind of resampling procedure do you think is appropriate? There are some proposals you can search the literature for (e.g., resample clusters as a whole; or resample clusters followed by resampling observations within each cluster; or residual bootstrapping both Level-1 and Level-2 residuals / random intercepts). None of these "nonparametric" bootstrapping methods are implemented in
lavaanbecause it is not clear whether any method is a good default option.The default is to provide delta-method SEs and CIs in
summary(..., ci=TRUE)orparamterEstimates(). If your sample size is not big enough for the delta-method to provide CIs with nominal coverage (and thus nominal Type I error rates), then your sample size certain also would not be big enough to trust your point estimates from a ML-SEM.Rather than a "nonparametric" bootstrap, the most straight-forward solution would be to use a parametric bootstrap, which is called a Monte Carlo CI in the SEM literature:
Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect effects. Communication Methods and Measures, 6(2), 77–98. https://doi.org/10.1080/19312458.2012.679848
Tofighi, D., & MacKinnon, D. P. (2016). Monte Carlo confidence intervals for complex functions of indirect effects. Structural Equation Modeling, 23(2), 194-205. https://doi.org/10.1080/10705511.2015.1057284
This is implemented in the
semToolspackage'smonteCarloCI()function, which provides CIs automatically for any user-defined parameters (such as indirect effects) in alavaanorlavaan.miobject.