Model ran in MPlus but not in lavaan--Did I "mistranslate"? Maybe model is not identified?

341 views
Skip to first unread message

Sam Bernecker

unread,
Dec 29, 2022, 4:41:08 PM12/29/22
to lavaan
Hi folks!

tl;dr summary: I'm getting the following warning when trying to run a CFA, and googling hasn't helped:
"Model estimation FAILED! Returning starting values.Error in Sigma.inv * sample.cov : non-conformable arrays"

The model ran in MPlus for a colleague, so I'm wondering if I somehow "translated" it wrong into lavaan. 

Background:
I'm trying to replicate a colleague's analyses that were originally performed in MPlus. I have the original data as well as his .inp files. He  split the data into exploratory and confirmatory sets before estimating several models, and I'm getting the same error for all the models in both data sets.

I'll just give an example of one model and data set--the final model in the confirmatory data set, which includes 514 participants with no missing data in the variables used in the model.

My code:
Note that the mplus2lavaan function had trouble parsing the models (it seemed particularly tripped up by commented-out lines in the MPlus syntax), so I had to translate these by hand, not being familiar with MPlus syntax. It's very possible that I've made some error in the translation. It's a pretty straightforward hierarchical measurement model, albeit with a lot of factors.

thriving_model_final_conf <- 

'FGrowmind =~ GrowM2 + GrowM5 + GrowM8
FCogFlex =~ CogFlex2 + CogFlex5 + CogFlex6
FReflect =~ Reflect1 + Reflect3 + Reflect5 + Reflect6
FProspect =~ Prosp4 + Prosp7 + Prosp8
FAttenReg =~ AttenReg1 + AttenReg3 + AttenReg5
FFocus =~ Focus4R + Focus7R + Focus10R
FEmoReg =~ EmoReg1 + EmoReg2 + EmoReg5 + EmoReg7
FActive =~ Active2 + Active7 + Active10
FNourish =~ Nourish2 + Nourish3 + Nourish7
FRest =~ Rest1 + Rest2 + Rest5
FConnect =~ Connect2 + Connect4 + Connect5
FExpress =~ Express1 + Express2 + Express5
FGive =~ Gives2 + Gives3 + Gives5

GCognitive =~ FGrowmind + FCogFlex + FProspect + FAttenReg
GEmotional =~ FFocus + FEmoReg
GPhysical =~ FActive + FNourish + FRest
GSocial =~ FConnect + FExpress + FGive
 
HThriving =~ GCognitive + GEmotional + GPhysical + GSocial'

thriving_final_conf_results <- lavaan(model = thriving_model_final_conf, data = df_thriving_final_conf)


What I've tried so far (all shots in the dark):
  • Everything below returns the warning, "Warning: lavaan WARNING: Model estimation FAILED! Returning starting values.Error in Sigma.inv * sample.cov : non-conformable arrays
    • Restricting the data frame to include only the variables in the model
    • Changing the data frame to a matrix (as.matrix())
    • Passing the lavaan function a covariance matrix rather than the raw data (using the code thriving_final_conf_results <- lavaan(model = thriving_model_final_conf, sample.cov = final_cov, sample.nobs = 514)
  • I also tried different estimators. 
    • GLS produces this warning: Warning: lavaan WARNING:Could not compute standard errors! The information matrix could not be inverted. This may be a symptom that the model is not identified.
    • WLS produces a warning and an error: Warning: lavaan WARNING: number of observations (514) too small to compute Gamma; Error in lav_samplestats_from_data(lavdata = lavdata, lavoptions = lavoptions,  lavaan ERROR: Gamma (NACOV) matrix is not positive-definite
    • ULS and DWLS produce these warnings: Warning: lavaan WARNING: number of observations (514) too small to compute Gamma; Warning: lavaan WARNING: Could not compute standard errors! The information matrix could not be inverted. This may be a symptom that the model is not identified.
    • DLS produces these warnings: Warning: lavaan WARNING: number of observations (514) too small to compute Gamma; Warning: lavaan WARNING: Model estimation FAILED! Returning starting values.
Is it possible that there are different default assumptions about unspecified parameters, or different default estimation methods, in lavaan vs. MPlus that would produce these errors? Any other ideas?

Many thanks, muchas gracias, grazie mille, merci mille fois ....

Sam Bernecker

unread,
Jan 3, 2023, 1:09:46 PM1/3/23
to lavaan
Bumping for visibility. Thanks for any help the community can provide! 

Jeremy Miles

unread,
Jan 3, 2023, 1:23:08 PM1/3/23
to lav...@googlegroups.com
Can you post the output? Or some data that lets us check it? I've got a couple of ideas, but I'm not sure which is right.



--
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/15c7172f-c409-4c19-9635-28ce10ebe9f4n%40googlegroups.com.

Yves Rosseel

unread,
Jan 3, 2023, 1:49:41 PM1/3/23
to lav...@googlegroups.com
> thriving_final_conf_results <- lavaan(model =
> thriving_model_final_conf, data = df_thriving_final_conf)

Try using the sem() function instead of the lavaan() function. To learn
about the difference, see https://doi.org/10.18637/jss.v048.i02 (page 12).

Yves.

Sam Bernecker

unread,
Jan 3, 2023, 3:41:24 PM1/3/23
to lav...@googlegroups.com
Thank you, Jeremy and Yves! Yes, that was the issue. Using the sem() or cfa() function works fine. My relief and joy at this easy fix even outweighs my embarrassment at having made such a forehead-slapping mistake. 

Happy New Year! 
Sam

--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/xtJElNmZfug/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/72e21e69-951c-145f-d8df-a955e1c66643%40gmail.com.
Reply all
Reply to author
Forward
0 new messages