Search code examples
rr-lavaan

Number of free parameters reported in Mplus vs lavaan


I ran a SEM model in R's lavaan and am now trying to replicate it in Mplus. I get almost identical results for factor loadings, coefficients, and fit measures so the replication looks successful. But I'm confused because lavaan and Mplus reports different number of freely estimated parameters.

As an illustration, below is the excerpt of lavaan summary:

lavaan 0.6-5 ended normally after 174 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                        254
  Number of equality constraints                    30
  Row rank of the constraints matrix                30

  Number of observations                          1622
  Number of missing patterns                       536

Model Test User Model:

  Test statistic                              2237.435
  Degrees of freedom                              1206
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                             19296.614
  Degrees of freedom                              1326
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.943
  Tucker-Lewis Index (TLI)                       0.937

and below is the excerpt of Mplus summary:

Mplus.version         "7"         
AnalysisType          "GENERAL"   
DataType              "INDIVIDUAL"
Estimator             "ML"        
Observations          "1622"      
NGroups               "1"         
NDependentVars        "51"        
NIndependentVars      "1"         
NContinuousLatentVars "12"        
Parameters            "224"       
ChiSqM_Value          "2237.424"  
ChiSqM_DF             "1206"      
ChiSqM_PValue         "0"         
ChiSqBaseline_Value   "19296.6"   
ChiSqBaseline_DF      "1326"      
ChiSqBaseline_PValue  "0"         
LL                    "-78566.54" 
UnrestrictedLL        "-77447.83" 
CFI                   "0.943"     
TLI                   "0.937"     
AIC                   "157581.1"  
BIC                   "158788.8"  
aBIC                  "158077.1"  
RMSEA_Estimate        "0.023"     
RMSEA_90CI_LB         "0.021"     
RMSEA_90CI_UB         "0.024"     
RMSEA_pLT05           "1"         
SRMR                  "0.048"     
AICC                  "157653.2" 

As you can see, lavaan reports there are 254 freely estimated parameters, whereas Mplus reports 224.

I noticed that if I subtract number of equality constraints (30) from 254, that returns 224, so was wondering if that explains the difference. Is my guess correct?

Thanks in advance for any suggestions!


Solution

  • When trying to validate lavaan with mplus (or vice-versa) I think it helps to use the lavaan function: mimic='mplus'
    When using the mimic function, you should find that your number of free parameters will match. Also, the output will more closely match the order of Mplus output, making your life easier. If you don't already have it, the paper by the author of Lavaan is very helpful, and can be found here: jstatsoft.org/article/view/v048i02/v48i02.pdf

    Here's some sample code.

    set.seed(9999)  
    mat=matrix(nrow=500,ncol=3)  
    mat[,1]<-rnorm(mean=5,sd=1,500)  
    mat[,2]<-rnorm(mat[,1],n=500)  
    mat[,3]<-rnorm(mat[,2],n=500)  
    colnames(mat)<-c(paste0('Q',1:3))  
    cfasyntax='F1=~Q1+Q2+Q3'  
    model=cfa(cfasyntax,data=mat,mimic='mplus')  
    summary(model)