lavaan and mplus. What we have to do when lavaan does not identify a model, but mplus does?

2,489 views
Skip to first unread message

Cursos Psi

unread,
Jul 22, 2018, 8:59:11 PM7/22/18
to lavaan
Hi there, Thanks for having this forum where we can solve our questions.
I'm moving from Mplus to lavaan, but something is going on when I compare simple results.

I have a dataset with 29 latent variables. My MPLUS code is:

 VARIABLE:
    NAMES ARE y1-y31;
    USEVARIABLES ARE y1-y29;
    MISSING IS *;
    CATEGORICAL IS y1-y29;

    ANALYSIS:
    PROCESS = 4;
    ESTIMATOR = WLSMV;

    MODEL:
    envolv by y1-y9;
    trein by y10-y12;
    cond by y13-y17;
    desemp by y18-y22;
    remun by y23-y26;
    IR by y27-y29;


In lavaan, the code is:
mod_cfa <-'
  #latent
  envolv =~ y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8 + y9
  trein =~ y10 + y11 + y12
  cond =~ y13 + y14 + y15 + y16 + y17
  desemp =~ y18 + y19 + y20 + y21 + y22
  remun =~ y23 + y24 + y25 + y26
  IR =~ y27 + y28 + y29'

cfa_all <- sem(model = mod_cfa, #get the model
              data = dados, #dataset
              estimator = 'WLSMV', #estimator for categorical
              ordered = colnames(dados[1:29]), #categorical measurement
              std.lv=TRUE)
  
Mplus gives me a report of my model with no warnings, but lavaan tells me: 
Warning message:
In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats,  :
  lavaan WARNING:
    The variance-covariance matrix of the estimated parameters (vcov)
    does not appear to be positive definite! The smallest eigenvalue
    (= -6.479800e-17) is smaller than zero. This may be a symptom that
    the model is not identified.


What is happening ?

Second question: there are any possibility to use "y1 by y9" in lavaan ?

Data is attached to this message.

Thank you.

data_lavaan.RData

Cursos Psi

unread,
Jul 22, 2018, 9:20:38 PM7/22/18
to lavaan
Just to update, when I remove the "ordered" function, it works, but I want to use this option because I'm analyzing results from likert scales.
Best

Jeremy Miles

unread,
Jul 23, 2018, 2:58:07 AM7/23/18
to lavaan
Couple of thoughts:

Do you have the same data? (This is usually where it goes wrong for me). Run Type =BASIC in Mplus, and psych::describe() or summary() in R.

You specify missing data, but I don't see any.

This is a warning, not an error, you still get model results. Do these match Mplus?

That's a heck of  a big model for a pretty small sample.

Jeremy

--
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 https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Cursos Psi

unread,
Jul 23, 2018, 9:10:49 AM7/23/18
to lavaan
Hi, Jeremy!
Thanks for you reply. 
Lavaan and MPLUS have virtually identical results. I've attached some figures to you see both outputs. What do you think is going on?

library(summarytools) 
view(dfSummary(dados)) #view


Jeremy Miles

unread,
Jul 24, 2018, 3:55:51 AM7/24/18
to lavaan

I suspect there's nothing to worry about.  The warning says that your lowest eigenvalue is -6.479800e-17, which is very, very close to zero.

However, the problem with non-identification is that your results are not stable. Run your model with different starting values, and see if it ends in the same place. If it does (or very close) then you probably don't need to worry.

Jeremy

Cursos Psi

unread,
Jul 24, 2018, 9:33:25 AM7/24/18
to lavaan
Then ok. Is it possible to ask lavaan to run my model using different starting values?
Thanks!

Terrence Jorgensen

unread,
Jul 24, 2018, 10:03:41 AM7/24/18
to lavaan
Is it possible to ask lavaan to run my model using different starting values?

Read about the start= argument in the ?lavOptions help page.  I think the default is start = "Mplus", so you could try start = "simple".  You can also manually insert your own custom start values in the model syntax.  Anything reasonable would do, as long as they are different.  For example:

envolv =~ start(1.2)*y1

or 

envolv =~ 1.2?y1


Terrence D. Jorgensen
Postdoctoral Researcher, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Cursos Psi

unread,
Jul 26, 2018, 4:41:13 PM7/26/18
to lavaan
Thanks much

Stas Kolenikov

unread,
Jul 27, 2018, 9:34:42 AM7/27/18
to lav...@googlegroups.com
With 160 parameters to estimate and 114 data points, you run out of data. `lavaan` tries to compute a 160x160 covariance matrix, but it only has a rank of 113, so when `lavaan` checks for zero eigenvalues (which asymptotically are a sign of underidentification), there are a few dozen of them. (I probably would have reported that the eigenvalue of e-17 is a numeric zero with a roundoff error, but that is a matter of style.) I think Mplus is just playing nice and does not want to scare you.



-- Stas Kolenikov, PhD, PStat (ASA, SSC)  @StatStas
-- Senior Scientist, Abt Associates @AbtDataScience
-- Program Chair (2018), Survey Research Methods Section of the American Statistical Association
-- Opinions stated in this email are mine only, and do not reflect the position of my employer
-- http://stas.kolenikov.name
 

To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages