MLR in lavaan

3,099 views
Skip to first unread message

Amber Gayle Thalmayer

unread,
Oct 19, 2012, 1:35:46 PM10/19/12
to lav...@googlegroups.com
Hello,

I have two questions that I hope are quite simple ...

1) I am trying to run a CFA model with missing = fiml and estimator = MLR (listed as such in my syntax). However, when I get my output I see that cases with any missing data have been excluded, and the estimator is listed as ML.
Any ideas what I might be doing wrong?

2) Does anyone know of a way to run Little's MCAR test in R?

Thank you!
Amber

yrosseel

unread,
Oct 19, 2012, 5:26:18 PM10/19/12
to lav...@googlegroups.com
On 10/19/2012 07:35 PM, Amber Gayle Thalmayer wrote:
> Hello,
>
> I have two questions that I hope are quite simple ...
>
> 1) I am trying to run a CFA model with missing = fiml and estimator =
> MLR (listed as such in my syntax). However, when I get my output I see
> that cases with any missing data have been excluded, and the estimator
> is listed as ML.
> Any ideas what I might be doing wrong?

No. Could you show us the syntax, the function, and the output?

> 2) Does anyone know of a way to run Little's MCAR test in R?

I believe the BaylorEdPsych package has it. Probably some other pacakges
too.

Yves.

Amber Gayle Thalmayer

unread,
Oct 19, 2012, 11:35:42 PM10/19/12
to lav...@googlegroups.com
Hi Yves,

Here is the syntax and output. This is for a model (TS), which has 45 items loading on a single factor. However the issue was the same when I ran a model with three correlated factors.
Thank you for any advice! I am just switching to lavaan from Mplus so I may be making any number of errors.

cfa(model = TS, meanstructure = TRUE, fixed.x = "default",
+     orthogonal = FALSE, std.lv = FALSE, data = NULL, std.ov = FALSE,
+     missing = "default", ordered = NULL, sample.cov = NULL, sample.mean = NULL,
+     sample.nobs = NULL, group = NULL, group.label = NULL,
+     group.equal = "", group.partial = "", cluster = NULL, constraints = '',
+     estimator = "MLR",
+     information = "default", se = "robust.mlr", test = "Yuan-Bentler",
+     bootstrap = 1000L, mimic = "MPlus", representation = "default",
+     do.fit = TRUE, control = list(), start = "Mplus",
+     verbose = FALSE, warn = TRUE, debug = FALSE)

** WARNING ** lavaan (0.5-9) model has NOT been fitted
** WARNING ** Estimates below are simply the starting values

  Number of observations                             0

  Estimator                                         ML

> summary (fit, fit.measures = TRUE, standardized=TRUE)
lavaan (0.5-9) converged normally after  54 iterations

                                                  Used       Total
  Number of observations                           545         624

  Estimator                                         ML
  Minimum Function Chi-square                 3825.763
  Degrees of freedom                               945
  P-value                                        0.000

Chi-square test baseline model:

  Minimum Function Chi-square                10627.684
  Degrees of freedom                               990
  P-value                                        0.000

Full model versus baseline model:

  Comparative Fit Index (CFI)                    0.701
  Tucker-Lewis Index (TLI)                       0.687

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)             -30534.610
  Loglikelihood unrestricted model (H1)     -28621.729

  Number of free parameters                         90
  Akaike (AIC)                               61249.221
  Bayesian (BIC)                             61636.291
  Sample-size adjusted Bayesian (BIC)        61350.596

Root Mean Square Error of Approximation:

  RMSEA                                          0.075
  90 Percent Confidence Interval          0.072  0.077
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.070

Parameter estimates:

  Information                                 Expected
  Standard Errors                             Standard

                   Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
Latent variables:
  TS =~
    Q_1               1.000                               0.297    0.396
    Q_2               1.728    0.210    8.217    0.000    0.513    0.550
    Q_3               1.902    0.221    8.597    0.000    0.565    0.615
    Q_4               1.651    0.211    7.836    0.000    0.490    0.496
    Q_5               1.709    0.210    8.124    0.000    0.507    0.536
    Q_6               1.513    0.181    8.339    0.000    0.449    0.570
    Q_7               1.071    0.193    5.542    0.000    0.318    0.283
    Q_8               1.387    0.175    7.944    0.000    0.412    0.510
    Q_9               2.468    0.273    9.049    0.000    0.733    0.715
    Q_10              2.238    0.262    8.532    0.000    0.664    0.603
    Q_11              0.082    0.069    1.195    0.232    0.024    0.053
    Q_12              1.772    0.228    7.779    0.000    0.526    0.488
    Q_13              2.115    0.235    8.997    0.000    0.628    0.702
    Q_14             -0.126    0.149   -0.847    0.397   -0.037   -0.037
    Q_15              2.625    0.289    9.080    0.000    0.779    0.723
    Q_16              1.113    0.183    6.077    0.000    0.330    0.322
    Q_17              1.188    0.219    5.422    0.000    0.353    0.274
    Q_18              2.320    0.266    8.713    0.000    0.689    0.638
    Q_19              1.201    0.188    6.389    0.000    0.356    0.346
    Q_20              1.851    0.223    8.295    0.000    0.549    0.562
    Q_21              2.019    0.246    8.203    0.000    0.599    0.548
    Q_22              1.880    0.226    8.334    0.000    0.558    0.569
    Q_23              2.402    0.270    8.909    0.000    0.713    0.681
    Q_24              2.422    0.269    9.014    0.000    0.719    0.706
    Q_25              2.159    0.256    8.444    0.000    0.641    0.588
    Q_26              0.247    0.102    2.425    0.015    0.073    0.109
    Q_27              1.722    0.222    7.747    0.000    0.511    0.484
    Q_28              2.090    0.258    8.092    0.000    0.620    0.531
    Q_29              1.774    0.225    7.873    0.000    0.527    0.501
    Q_30              1.452    0.182    7.995    0.000    0.431    0.517
    Q_31              2.373    0.264    8.974    0.000    0.704    0.697
    Q_32              0.276    0.083    3.342    0.001    0.082    0.154
    Q_33              2.328    0.267    8.709    0.000    0.691    0.638
    Q_34              1.355    0.209    6.483    0.000    0.402    0.354
    Q_35              1.122    0.163    6.876    0.000    0.333    0.389
    Q_36              2.185    0.253    8.646    0.000    0.648    0.625
    Q_37              1.865    0.235    7.921    0.000    0.554    0.507
    Q_38              1.757    0.228    7.717    0.000    0.521    0.480
    Q_39              1.093    0.161    6.785    0.000    0.324    0.381
    Q_40              2.712    0.308    8.808    0.000    0.805    0.658
    Q_41              2.217    0.271    8.192    0.000    0.658    0.546
    Q_42              2.555    0.278    9.176    0.000    0.758    0.749
    Q_43              1.840    0.213    8.639    0.000    0.546    0.624
    Q_44              1.016    0.149    6.794    0.000    0.301    0.382
    Q_45              1.687    0.227    7.439    0.000    0.501    0.447

Variances:
    Q_1               0.473    0.029                      0.473    0.843
    Q_2               0.606    0.038                      0.606    0.697
    Q_3               0.523    0.033                      0.523    0.621
    Q_4               0.737    0.045                      0.737    0.754
    Q_5               0.638    0.039                      0.638    0.713
    Q_6               0.419    0.026                      0.419    0.675
    Q_7               1.164    0.071                      1.164    0.920
    Q_8               0.481    0.030                      0.481    0.740
    Q_9               0.513    0.033                      0.513    0.489
    Q_10              0.771    0.048                      0.771    0.636
    Q_11              0.212    0.013                      0.212    0.997
    Q_12              0.884    0.054                      0.884    0.762
    Q_13              0.405    0.026                      0.405    0.507
    Q_14              1.004    0.061                      1.004    0.999
    Q_15              0.553    0.035                      0.553    0.477
    Q_16              0.947    0.058                      0.947    0.897
    Q_17              1.526    0.093                      1.526    0.925
    Q_18              0.689    0.043                      0.689    0.592
    Q_19              0.931    0.057                      0.931    0.880
    Q_20              0.652    0.040                      0.652    0.684
    Q_21              0.837    0.052                      0.837    0.700
    Q_22              0.651    0.040                      0.651    0.676
    Q_23              0.587    0.037                      0.587    0.536
    Q_24              0.519    0.033                      0.519    0.501
    Q_25              0.779    0.048                      0.779    0.655
    Q_26              0.445    0.027                      0.445    0.988
    Q_27              0.854    0.053                      0.854    0.766
    Q_28              0.979    0.060                      0.979    0.718
    Q_29              0.829    0.051                      0.829    0.749
    Q_30              0.508    0.031                      0.508    0.732
    Q_31              0.526    0.033                      0.526    0.515
    Q_32              0.276    0.017                      0.276    0.976
    Q_33              0.697    0.044                      0.697    0.594
    Q_34              1.127    0.069                      1.127    0.874
    Q_35              0.620    0.038                      0.620    0.848
    Q_36              0.656    0.041                      0.656    0.609
    Q_37              0.885    0.055                      0.885    0.743
    Q_38              0.906    0.056                      0.906    0.769
    Q_39              0.620    0.038                      0.620    0.855
    Q_40              0.846    0.053                      0.846    0.566
    Q_41              1.018    0.063                      1.018    0.702
    Q_42              0.449    0.029                      0.449    0.438
    Q_43              0.469    0.029                      0.469    0.611
    Q_44              0.533    0.033                      0.533    0.854
    Q_45              1.001    0.061                      1.001    0.800
    TS                0.088    0.019                      1.000    1.000

yrosseel

unread,
Oct 20, 2012, 5:11:33 AM10/20/12
to lav...@googlegroups.com
On 10/20/2012 05:35 AM, Amber Gayle Thalmayer wrote:
> Hi Yves,
>
> Here is the syntax and output. This is for a model (TS), which has 45
> items loading on a single factor. However the issue was the same when I
> ran a model with three correlated factors.
> Thank you for any advice! I am just switching to lavaan from Mplus so I
> may be making any number of errors.
>
> cfa(model = TS, meanstructure = TRUE, fixed.x = "default",
> + orthogonal = FALSE, std.lv = FALSE, data = NULL, std.ov = FALSE,
> + missing = "default", ordered = NULL, sample.cov = NULL,
> sample.mean = NULL,
> + sample.nobs = NULL, group = NULL, group.label = NULL,
> + group.equal = "", group.partial = "", cluster = NULL, constraints
> = '',
> + estimator = "MLR",
> + information = "default", se = "robust.mlr", test = "Yuan-Bentler",
> + bootstrap = 1000L, mimic = "MPlus", representation = "default",
> + do.fit = TRUE, control = list(), start = "Mplus",
> + verbose = FALSE, warn = TRUE, debug = FALSE)

If this is indeed the function call you have been using, it is no
surprise you get:

> ** WARNING ** lavaan (0.5-9) model has NOT been fitted
> ** WARNING ** Estimates below are simply the starting values

Because there is no data: data=NULL and sample.cov=NULL. In R, there is
no need to specify *all* arguments. Many arguments have reasonable
default values. You only need to specify those that are important. For
example, in your case, you probably want something like:

fit <- cfa(model=TS, data=myData, missing="ml", estimator="MLR")
summary(fit, fit.measures=TRUE)

(where I have assumed that your data is in a dat.frame called myData)

However, this output

> > summary (fit, fit.measures = TRUE, standardized=TRUE)
> lavaan (0.5-9) converged normally after 54 iterations
>
> Used Total
> Number of observations 545 624
>
> Estimator ML
> Minimum Function Chi-square 3825.763
> Degrees of freedom 945
> P-value 0.000
[snip]

is not the one that corresponds with the functional call at the
beginning of your post; it contains data. What is the function call that
gave you this output?

Yves.

Amber Gayle

unread,
Oct 20, 2012, 2:44:20 PM10/20/12
to lav...@googlegroups.com
Hi Yves,

Thank you for looking at this.
Prior to that syntax, I had told R to read my data from a csv file,
then I specified my model on a separate line. Sorry I didn't include.
But anyway, editing the syntax as suggested has solved the problem.

Thank you again for the quick and helpful reply!
Amber
> --
> You received this message because you are subscribed to the Google Groups
> "lavaan" group.
> To post to this group, send email to lav...@googlegroups.com.
> Visit this group at http://groups.google.com/group/lavaan?hl=en.
>
>

Amber Gayle

unread,
Oct 20, 2012, 3:29:03 PM10/20/12
to lav...@googlegroups.com
Ok one more question, in case you have any suggestions for me!

In my 45-item survey, I tested a 'total score' model, then a
three-factor subscale model. (And I got the same results in lavaan as
in Mplus.) Now I would like to test a bi-level model that includes the
total score (all items) plus the three subscales, such that all items
load onto two factors.
This is to replicate a published study (using EQs, which of course
should not matter) in which this was the best fitting model.

I used the same syntax, but specified that the factors should be orthogonal:
> fit <- cfa(model=Intended.bi, data=survey2, missing="ml", estimator="MLR")

Mplus says that none of the bi-level models I tried will converge, and
I understood this to be because they so poorly matched the data.

In lavaan, I get the following error messages, followed by output for
the three-factor subscale model (simply ignoring the 4th, total score
factor). Before I give up, and conclude that this model simply doesn't
fit, I wanted to ask if you think these error messages suggest any
other potential explanations for this failure to converge? :

Error in computeOmega(Sigma.hat = Sigma.hat, Mu.hat = Mu.hat,
samplestats = samplestats, :
computeGradient: Sigma.hat is not positive definite

Error in computeOmega(Sigma.hat = Sigma.hat, Mu.hat = Mu.hat,
samplestats = samplestats, :
computeGradient: Sigma.hat is not positive definite
In addition: Warning message:
In estimateVCOV(lavaanModel, samplestats = lavaanSampleStats, options
= lavaanOptions, :
lavaan WARNING: could not compute standard errors!

Thank you for any advice,
Amber

yrosseel

unread,
Oct 20, 2012, 6:57:22 PM10/20/12
to lav...@googlegroups.com
On 10/20/2012 09:29 PM, Amber Gayle wrote:
> Ok one more question, in case you have any suggestions for me!
>
> In my 45-item survey, I tested a 'total score' model, then a
> three-factor subscale model. (And I got the same results in lavaan as
> in Mplus.) Now I would like to test a bi-level model that includes the
> total score (all items) plus the three subscales, such that all items
> load onto two factors.
> This is to replicate a published study (using EQs, which of course
> should not matter) in which this was the best fitting model.
>
> I used the same syntax, but specified that the factors should be orthogonal:
>> fit <- cfa(model=Intended.bi, data=survey2, missing="ml", estimator="MLR")
>
> Mplus says that none of the bi-level models I tried will converge, and
> I understood this to be because they so poorly matched the data.
>
> In lavaan, I get the following error messages

The error messages are not very user-friendly. But basically, they mean:
trouble! The model does not converge. Usually, I would be eager to see
if other software would succeed. But as you write, Mplus does not seem
to converge either.

followed by output for
> the three-factor subscale model (simply ignoring the 4th, total score
> factor).

What you are seeing is the output of the previous model (the one that
converged).

> fit, I wanted to ask if you think these error messages suggest any
> other potential explanations for this failure to converge? :

Well, I may have some additional tricks that we may want to try for your
data. Would you be able to send me your model syntax and the data (or a
snippet of the data) so that I can reproduce the error messages? I would
be able to tell you exactly why it fails.

Yves.


Jong-Hwa

unread,
Feb 13, 2013, 9:21:04 AM2/13/13
to lav...@googlegroups.com
Dear Yves,

My question is related to 'MLR' with the cfa() example, HolzingerSwineford1939. In my knowledge based on some explanations from Mplus and lavaan, the estimator, MLR, could possibly use for the non-normal dataset, in order words, the dataset which could not pass successfully the multivariate normality test. I conducted a normality test for the dataset, HolzingerSwineford1939:

require(mvnormtest)
mshapiro.test(t(HolzingerSwineford1939[, 7:15])
====================
require(psych)
mardia(HolzingerSwineford1939[, 7:15])

Based on both functions, HolzingerSwineford1939's variables, x1 ~~~x9 are non-normal in the multivariate test for normality. Then, I think that your cfa() example possibly should be like this: fit <- cfa(HS.model, data=HolzingerSwineford1939, estimator="MLR") Am I right? Then, I was wondering why you deliberately ignore the MLR estimator. Thank you in advance.

Jong-Hwa

yrosseel

unread,
Feb 14, 2013, 9:23:48 AM2/14/13
to lav...@googlegroups.com
On 02/13/2013 03:21 PM, Jong-Hwa wrote:
> Dear Yves,
>
> My question is related to 'MLR' with the cfa() example,
> HolzingerSwineford1939. In my knowledge based on some explanations from
> Mplus and lavaan, the estimator, MLR, could possibly use for the
> non-normal dataset, in order words, the dataset which could not pass
> successfully the multivariate normality test. I conducted a normality
> test for the dataset, HolzingerSwineford1939:
>
> require(mvnormtest)
> mshapiro.test(t(HolzingerSwineford1939[, 7:15])
> ====================
> require(psych)
> mardia(HolzingerSwineford1939[, 7:15])
>
> Based on both functions, HolzingerSwineford1939's variables, x1 ~~~x9
> are non-normal in the multivariate test for normality. Then, I think
> that your cfa() example possibly should be like this: fit <-
> cfa(HS.model, data=HolzingerSwineford1939, estimator="MLR") Am I right?
> Then, I was wondering why you deliberately ignore the MLR estimator.

You raise an excellent point. I have wondered about this too (should I
not make estimator="MLR" the default?), but have not done so yet.

Why? It would be different from traditional SEM software (where plain
vanilla ML is the default), and it would (I think) confuse many people.

But what do other people on this list think?

Yves.

Jong-Hwa

unread,
Mar 15, 2013, 10:07:34 PM3/15/13
to lav...@googlegroups.com
A couple of days ago, I had a chat with a friend of mine on the list of estimators provided by Lavaan and AMOS. As a new comer in SEM research, I could not persuasively explain which one is better for non-normal data by default: WLS vs. MLR vs. one among others in lavaan.

Could you recommend any paper or report on MLR for me? Thank you in advance.

regards,

Jong-Hwa



2013년 2월 14일 목요일 오후 11시 23분 48초 UTC+9, Yves Rosseel 님의 말:

yrosseel

unread,
Mar 16, 2013, 5:25:29 AM3/16/13
to lav...@googlegroups.com
On 03/16/2013 03:07 AM, Jong-Hwa wrote:
> A couple of days ago, I had a chat with a friend of mine on the list of
> estimators provided by Lavaan and AMOS. As a new comer in SEM research,
> I could not persuasively explain which one is better for non-normal data
> by default: WLS vs. MLR vs. one among others in lavaan.
>
> Could you recommend any paper or report on MLR for me? Thank you in advance.


Section 7.1 of the lavaan paper (http://www.jstatsoft.org/v48/i02)
contains a brief discussion with pointers to the literature.

Yves.

SHIN Jong-Hwa

unread,
Mar 18, 2013, 4:59:17 AM3/18/13
to lav...@googlegroups.com
Thank you very much for your advice.

May I possibly take a preference to choose one among three options in your paper? Are they equally recommendable? What is your practical choice? Advanced ML series seems not available in AMOS, I think.

Thank you in advance.

Jong-Hwa

2013. 3. 16., 오후 6:25, yrosseel <yros...@gmail.com> 작성:
> --
> 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 post to this group, send email to lav...@googlegroups.com.
> Visit this group at http://groups.google.com/group/lavaan?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

yrosseel

unread,
Mar 18, 2013, 5:08:33 AM3/18/13
to lav...@googlegroups.com
On 03/18/2013 09:59 AM, SHIN Jong-Hwa wrote:
> Thank you very much for your advice.
>
> May I possibly take a preference to choose one among three options in
> your paper? Are they equally recommendable? What is your practical
> choice? Advanced ML series seems not available in AMOS, I think.

You should avoid ADF/WLS (unless you have a huge sample size, say
N>5000). MLR and bootstrapping work equally well. For some subtle
differences, see

Yuan, KH & Hayashi K (2006). Standard errors in covariance structure
models: Asymptotics versus bootstrap. British Journal of Mathematical
and Statistical Psychology, Vol. 59, No. 2. (November 2006), pp.
397-417, doi:10.1348/000711005x85896

Bootstrapping, of course, takes (much) more time.

Yves.

andina almira

unread,
Jun 6, 2014, 7:55:34 PM6/6/14
to lav...@googlegroups.com

Hi,
I've just read this topic. coincidentally, this is associated with my confusion.

On Monday, March 18, 2013 4:08:33 PM UTC+7, Yves Rosseel wrote:

Yuan, KH & Hayashi K (2006). Standard errors in covariance structure
models: Asymptotics versus bootstrap. British Journal of Mathematical
and Statistical Psychology, Vol. 59, No. 2. (November 2006), pp.
397-417, doi:10.1348/000711005x85896

Yves.

about the journal (Yuan, KH & Hayashi), I've reach that and there are three SEs (based on equations (9), (12), and (14)). But I still can't differentiate se which is used in MLM and MLR?Is it based on equations (9), (12), or (14)?

Thanks
Andin

yrosseel

unread,
Jun 15, 2014, 5:44:33 AM6/15/14
to lav...@googlegroups.com
Have a look here:

http://users.ugent.be/~yrosseel/lavaan/utrecht2010.pdf

where the formulas for MLM and MLR are explained.

Yves.
Reply all
Reply to author
Forward
0 new messages