bootstrap with MLR in lavaan

1,183 views
Skip to first unread message

Jose Luis Ventura Leon

unread,
Oct 1, 2021, 9:05:40 AM10/1/21
to lavaan
Hi everyone

Does anyone have an idea why I can't run a bootstrap with MLR in lavaan. Below is the code.
 
```
fit <- lavaan::sem(model, data = Data_new1, estimator = "MLR", se = "bootstrap", bootstrap = 5000)
```

I get this error
```
Error in lav_options_set(opt) : 
  lavaan ERROR: use ML estimator for bootstrap
```
Best regards
Jose Ventura-Leon

Chesnut, Ryan

unread,
Oct 1, 2021, 9:18:24 AM10/1/21
to lav...@googlegroups.com
I’m sure there is a more technical answer, but I believe ML and MLR will produce similar parameter estimates but different standard errors. MLR corrects the standard errors for violations of specific assumptions, such as normality. Bootstrapping also corrects the standard errors, so in essence, MLR and bootstrapping are redundant.

Sent from my iPad

On Oct 1, 2021, at 9:06 AM, Jose Luis Ventura Leon <jventu...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/23681488-eff5-4140-902c-ecf1a841aa4bn%40googlegroups.com.

Pat Malone

unread,
Oct 1, 2021, 3:55:51 PM10/1/21
to lav...@googlegroups.com
Ryan has it right. The MLR point estimates are the same as ML.

If you want bootstrapped CIs with MLR:

Step 1. Estimate with MLR to get scaled fit (and check for surprises with a quicker run). Disregard tests of parameter estimates.

Step 2. Estimate with ML and bootstrap to evaluate parameter estimates with respect to their CIs. Disregard fit.

Pat



--
Patrick S. Malone, PhD
Sr Research Statistician, FAR HARBΦR
This message may contain confidential information; if you are not the intended recipient please notify the sender and delete the message.

Shu Fai Cheung

unread,
Oct 1, 2021, 11:37:17 PM10/1/21
to lavaan
I am not 100% certain how the value of "estimator" translates to other options. If I read the document correctly, then setting the "estimator" to "MLR" will set "estimator" to "ML", "test" to "yuan.bentler.mplus", and "se" to "robust.cluster."

Therefore, one possible way to do that in one single call to sem is setting the arguments as below:

estimator = "ML", test = "yuan.bentler.mplus", se = "bootstrap"

This is an illustration:

```
# Example adapted from https://lavaan.ugent.be/tutorial/mediation.html

options(width = 132)
library(lavaan)
set.seed(1234)
X <- rnorm(100)
M <- 0.5*X + rnorm(100)
Y <- 0.7*M + rnorm(100)
Data <- data.frame(X = X, Y = Y, M = M)
model <- ' # mediator
             M ~ a*X
             Y ~ b*M
           # indirect effect (a*b)
             ab := a*b
         '
fit_mlr <- sem(model, Data, estimator = "MLR")
set.seed(4143)
fit_boot <- sem(model, Data, estimator = "ML", se = "bootstrap")
set.seed(4143)
fit_boot_mlr <- sem(model, Data, estimator = "ML", test = "yuan.bentler.mplus", se = "bootstrap")
summary(fit_mlr)
summary(fit_boot)
summary(fit_boot_mlr)

# The following two sets of SEs should be identical (bootstrapping SEs)
parameterEstimates(fit_boot, boot.ci.type = "perc")$se
parameterEstimates(fit_boot_mlr, boot.ci.type = "perc")$se

# The following output should have SEs different from those above (ML SE)
parameterEstimates(fit_mlr)$se

# The following two outputs should have the same p-values (scaled)
anova(fit_mlr)
anova(fit_boot_mlr)

# The following output should have a different p-value (unscaled)
anova(fit_boot)
```

I tested this only for a single-level single-group model. Not sure if this also works for more complicated models.

-- Shu Fai

Pat Malone

unread,
Oct 2, 2021, 11:14:22 AM10/2/21
to lav...@googlegroups.com
Yes, I think that would work fine--my two-step suggestion takes less tinkering with defaults, but you're right, takes two steps when it could be done in one.

HOWEVER, I missed that the original question was about bootstrap SEs, not bootstrap CIs. Bootstrap SEs don't have all the advantages bootstrap CIs do, so it depends on why the OP wants to use the bootstrap. On the other hand, 5000 is almost certainly far more resamples than you need for stable estimates of SEs.

Pat

Jose Luis Ventura Leon

unread,
Oct 10, 2021, 5:28:12 PM10/10/21
to lavaan
Thank you all for your answers. I have better understood my question. 
Thanks also for the codes provided Shu Fai.

Greetings to all
JL
Reply all
Reply to author
Forward
0 new messages