Goal:
Obtain bootstrap confidence intervals for the standardized estimates of a complex sampling SEM
Details:
I am trying to obtain 95% bootstrap confidence intervals for the standardized estimates of a complex sampling SEM.
The survey design uses resampling method bootstrapping and the SEM is estimated on the bootstrapped covariance matrices. Lavaan survey corrects SEM for the fact that respondents are sampled within municipalities (multi-stage sampling).
The parameterEstimates method provides 95% bootstrap confidence intervals for the non-standardized estimates but not for the standardized methods.
When using bootstrapLavaan to obtain 95% bootstrap confidence intervals for the standardized estimates the error "Failed creating sampling statistics".
Please find my R code below.
R code:
#Complex survey design with resampling method bootstrap
des.gemeente <- svydesign(ids = ~ï..Gemeente, probs = ~1, data = dataBert)
bdes.gemeente <- as.svrepdesign(des.gemeente,type="bootstrap", replicates=5000)
finstructmodel <- '
# latent variable definitions
CREA_L =~ CREA1 + CREA2 + CREA3 + CREA5 + CREA6 + CREA7
KNO_L =~ KNO2 + KNO3 + KNO4
PLA_L =~ PLA1 + PLA2 + PLA3 + PLA4 + PLA6 + PLA7
EAS_L =~ EAS1 + EAS2 + EAS3 + EAS4
USE_L =~ USE1 + USE2 + USE3 + USE4
COM_L =~ COM3 + COM4 + COM5 + COM6
# variances and covariances
CREA2 ~ ~ CREA3
PLA2 ~ ~ PLA7
PLA3 ~ ~ PLA4
EAS1 ~ ~ EAS3
EAS2 ~ ~ EAS3
USE1 ~ ~ USE4
USE2 ~ ~ USE3
COM4 ~ ~ COM6
EAS_L ~ ~ USE_L
#regressions
EAS_L ~ a*CREA_L + c*KNO_L + e*PLA_L
USE_L ~ b*CREA_L + d*KNO_L + f*PLA_L
COM_L ~ g*EAS_L + h*USE_L + i*CREA_L
# indirect effect
ind_ag := a*g
ind_bh := b*h
ind_cg := c*g
ind_dh := d*h
ind_eg := e*g
ind_fh := f*h
#total effects from 1st stage on COM_L in third stage
tot_CREA_COM := i+ind_ag+ind_bh
tot_KNO_COM := ind_cg+ind_dh
tot_PLA_COM := ind_eg+ind_fh
#total effect on COM_L in third stage
total := i+ind_ag+ind_bh+ind_cg+ind_dh+ind_eg+ind_fh
#total indirect effect
total_ind := total-i'
finstructfit <- sem(finstructmodel,data=dataBert,estimator = "MLM")
#Structural model on bootstrapped covariance matrices correcting for respondents being clustered within municipalities
fit.finstruct.surveyb <- lavaan.survey(finstructfit, bdes.gemeente, estimator = "MLM")
parameterEstimates(fit.finstruct.surveyb,ci = TRUE,level = 0.95, boot.ci.type = "perc",standardized=TRUE)
#parameterEstimates provides 95% bootstrap cfis for the non-standardized estimates but not for the standardized estimates (neither for std.LV, std.ALL nor std.nox)
standardizedSolution(fit.finstruct.surveyb)
#provides the standardized estimates without 95% bootstrap confidence intervals
#trying to obtain 95% bootstrap confidence intervals for the standardized estimates using bootstrapLavaan
out <- bootstrapLavaan(fit.finstruct.surveyb, R = 5000, FUN = function(x) {
standardizedSolution(x)$est}, verbose = TRUE)
#returns Error: failed creating sample statistics