very good fit indices but a warning message of latent variables with non positive definite cov matrix

964 views
Skip to first unread message

maryam nasseri

unread,
Mar 26, 2019, 7:27:55 AM3/26/19
to lav...@googlegroups.com
HI everyone,

I conducted a CFA/SEM test on a 3-factor model called lex.modelnew (one factor has a single indicator) which gives me the warning that "covariance matrix of latent variables is not positive definite" and I used lavInspect(fit, "cov.lv") with results that I show below; but when I checked goodness-of-fit indices, they all show very good fit.

Then I changed the model to a 2-factor model called lex.model2F (I moved the single indicator variable to its closely theoretically related factor) and the warning disappears but the fit indices show the same or very close results as the 3-factor model (all show very good fit).

-- Since both models' fit indices show very good fit, I was wondering which model to stick to and should I regard or disregard the warning message. The 3-factor model is the exact model taken from the theory/literature on the subject. Also the covariance matrix of latent variables for both models include a large positive value and negative values; what does a negative value here mean?

Below I'm pasting the exact code and results I got; many thanks to anyone who could help:

P.S: Terrence suggested the use of ridge in the sem function below:

lex.modelnew<- 'group1=~ ld
+ group2=~ mtld + vocd + ndwerz + ndwesz + mattr + hdd + logttr + rttr + uber + lv + nv + vv1 + vv2 + cvv1 + adjv  
+ group3=~ ls1 + ls2 + vs2 + cvs1'

 fitnew<- sem(lex.modelnew, sample.cov = shrink.cov, sample.nobs=210, ridge = .01)
Warning message:
In lav_object_post_check(object) :
  lavaan WARNING: covariance matrix of latent variables
                is not positive definite;
                use lavInspect(fit, "cov.lv") to investigate.

 lavInspect(fitnew, "cov.lv")
       group1  group2  group3 
group1   0.003                
group2   0.207 135.422        
group3   0.000  -0.334   0.001

summary(fitnew, ci = TRUE, fit.measures=TRUE, standardized = TRUE) 
lavaan 0.6-3 ended normally after 342 iterations

  Optimization method                           NLMINB
  Number of free parameters                         42

  Number of observations                           210

  Estimator                                         ML
  Model Fit Test Statistic                      43.786
  Degrees of freedom                               168
  P-value (Chi-square)                           1.000

Model test baseline model:

  Minimum Function Test Statistic             2206.790
  Degrees of freedom                               190
  P-value                                        0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    1.000
  Tucker-Lewis Index (TLI)                       1.070

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)                376.739
  Loglikelihood unrestricted model (H1)        398.632

  Number of free parameters                         42
  Akaike (AIC)                                -669.477
  Bayesian (BIC)                              -528.899
  Sample-size adjusted Bayesian (BIC)         -661.979

Root Mean Square Error of Approximation:

  RMSEA                                          0.000
  90 Percent Confidence Interval          0.000  0.000
  P-value RMSEA <= 0.05                          1.000

Standardized Root Mean Square Residual:

  SRMR                                           0.023

Parameter Estimates:

  Information                                 Expected
  Information saturated (h1) model          Structured
  Standard Errors                             Standard

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
  group1 =~                                                                               
    ld                1.000                               1.000    1.000    0.057    1.000
  group2 =~                                                                               
    mtld              1.000                               1.000    1.000   11.637    0.732
    vocd              1.881    0.179   10.535    0.000    1.531    2.231   21.887    0.721
    ndwerz            0.102    0.010   10.619    0.000    0.083    0.121    1.189    0.727
    ndwesz            0.133    0.012   10.698    0.000    0.109    0.157    1.548    0.732
    mattr             0.005    0.000   10.702    0.000    0.004    0.005    0.053    0.732
    hdd               0.004    0.000   10.645    0.000    0.003    0.005    0.048    0.728
    logttr            0.004    0.000   10.732    0.000    0.003    0.004    0.044    0.734
    rttr              0.145    0.013   10.745    0.000    0.118    0.171    1.685    0.735
    uber              0.133    0.012   10.748    0.000    0.109    0.157    1.548    0.735
    lv                0.004    0.000   10.662    0.000    0.003    0.005    0.050    0.729
    nv                0.004    0.000   10.539    0.000    0.003    0.005    0.045    0.721
    vv1               0.005    0.000   10.558    0.000    0.004    0.006    0.056    0.723
    vv2               0.002    0.000    5.332    0.000    0.001    0.002    0.021    0.374
    cvv1              0.014    0.001   10.654    0.000    0.012    0.017    0.166    0.729
    adjv              0.004    0.000   10.582    0.000    0.003    0.004    0.042    0.724
  group3 =~                                                                               
    ls1               1.000                               1.000    1.000    0.029    0.485
    ls2              -1.636    0.237   -6.904    0.000   -2.101   -1.172   -0.047   -0.720
    vs2             -15.573    2.253   -6.911    0.000  -19.990  -11.157   -0.446   -0.721
    cvs1             -4.538    0.656   -6.918    0.000   -5.824   -3.253   -0.130   -0.723

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
  group1 ~~                                                                               
    group2            0.207    0.051    4.074    0.000    0.107    0.306    0.314    0.314
    group3           -0.000    0.000   -3.306    0.001   -0.001   -0.000   -0.291   -0.291
  group2 ~~                                                                               
    group3           -0.334    0.058   -5.756    0.000   -0.447   -0.220   -1.001   -1.001

Variances:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
   .ld                0.000                               0.000    0.000    0.000    0.000
   .mtld            117.489   12.178    9.648    0.000   93.621  141.358  117.489    0.465
   .vocd            441.904   45.635    9.684    0.000  352.462  531.346  441.904    0.480
   .ndwerz            1.264    0.131    9.666    0.000    1.008    1.520    1.264    0.472
   .ndwesz            2.079    0.215    9.648    0.000    1.657    2.501    2.079    0.465
   .mattr             0.002    0.000    9.647    0.000    0.002    0.003    0.002    0.464
   .hdd               0.002    0.000    9.660    0.000    0.002    0.002    0.002    0.470
   .logttr            0.002    0.000    9.640    0.000    0.001    0.002    0.002    0.461
   .rttr              2.421    0.251    9.637    0.000    1.928    2.913    2.421    0.460
   .uber              2.042    0.212    9.636    0.000    1.627    2.457    2.042    0.460
   .lv                0.002    0.000    9.656    0.000    0.002    0.003    0.002    0.468
   .nv                0.002    0.000    9.683    0.000    0.002    0.002    0.002    0.479
   .vv1               0.003    0.000    9.679    0.000    0.002    0.003    0.003    0.478
   .vv2               0.003    0.000   10.163    0.000    0.002    0.003    0.003    0.860
   .cvv1              0.024    0.003    9.658    0.000    0.019    0.029    0.024    0.469
   .adjv              0.002    0.000    9.674    0.000    0.001    0.002    0.002    0.475
   .ls1               0.003    0.000   10.056    0.000    0.002    0.003    0.003    0.765
   .ls2               0.002    0.000    9.301    0.000    0.002    0.002    0.002    0.482
   .vs2               0.184    0.020    9.289    0.000    0.145    0.222    0.184    0.480
   .cvs1              0.015    0.002    9.277    0.000    0.012    0.019    0.015    0.477
    group1            0.003    0.000   10.247    0.000    0.003    0.004    1.000    1.000
    group2          135.422   22.239    6.090    0.000   91.835  179.009    1.000    1.000
    group3            0.001    0.000    3.643    0.000    0.000    0.001    1.000    1.000



 lex.model2F<- 'group1=~ mtld + vocd + ndwerz + ndwesz + mattr + hdd + logttr + rttr + uber + lv + nv + vv1 + vv2 + cvv1 + adjv + ld
group2=~ ls1 + ls2 + vs2 + cvs1'

fit2F<- sem(lex.model2F, sample.cov = shrink.cov, sample.nobs=210, ridge = .01)

summary(fit2F, ci = TRUE, fit.measures=TRUE, standardized = TRUE)
lavaan 0.6-3 ended normally after 329 iterations

  Optimization method                           NLMINB
  Number of free parameters                         41

  Number of observations                           210

  Estimator                                         ML
  Model Fit Test Statistic                      44.124
  Degrees of freedom                               169
  P-value (Chi-square)                           1.000

Model test baseline model:

  Minimum Function Test Statistic             2206.790
  Degrees of freedom                               190
  P-value                                        0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    1.000
  Tucker-Lewis Index (TLI)                       1.070

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)                376.570
  Loglikelihood unrestricted model (H1)        398.632

  Number of free parameters                         41
  Akaike (AIC)                                -671.140
  Bayesian (BIC)                              -533.908
  Sample-size adjusted Bayesian (BIC)         -663.820

Root Mean Square Error of Approximation:

  RMSEA                                          0.000
  90 Percent Confidence Interval          0.000  0.000
  P-value RMSEA <= 0.05                          1.000

Standardized Root Mean Square Residual:

  SRMR                                           0.023

Parameter Estimates:

  Information                                 Expected
  Information saturated (h1) model          Structured
  Standard Errors                             Standard

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
  group1 =~                                                                               
    mtld              1.000                               1.000    1.000   11.638    0.732
    vocd              1.881    0.179   10.536    0.000    1.531    2.231   21.890    0.721
    ndwerz            0.102    0.010   10.620    0.000    0.083    0.121    1.189    0.727
    ndwesz            0.133    0.012   10.699    0.000    0.109    0.157    1.548    0.732
    mattr             0.005    0.000   10.703    0.000    0.004    0.005    0.053    0.732
    hdd               0.004    0.000   10.646    0.000    0.003    0.005    0.048    0.728
    logttr            0.004    0.000   10.732    0.000    0.003    0.004    0.044    0.734
    rttr              0.145    0.013   10.745    0.000    0.118    0.171    1.685    0.735
    uber              0.133    0.012   10.748    0.000    0.109    0.157    1.548    0.735
    lv                0.004    0.000   10.663    0.000    0.003    0.005    0.050    0.729
    nv                0.004    0.000   10.537    0.000    0.003    0.005    0.045    0.721
    vv1               0.005    0.000   10.563    0.000    0.004    0.006    0.056    0.723
    vv2               0.002    0.000    5.329    0.000    0.001    0.002    0.021    0.374
    cvv1              0.014    0.001   10.656    0.000    0.012    0.017    0.166    0.729
    adjv              0.004    0.000   10.584    0.000    0.003    0.004    0.042    0.724
    ld                0.002    0.000    4.402    0.000    0.001    0.002    0.018    0.310
  group2 =~                                                                               
    ls1               1.000                               1.000    1.000    0.029    0.484
    ls2              -1.641    0.238   -6.891    0.000   -2.108   -1.174   -0.047   -0.720
    vs2             -15.603    2.263   -6.895    0.000  -20.039  -11.168   -0.446   -0.721
    cvs1             -4.547    0.659   -6.902    0.000   -5.839   -3.256   -0.130   -0.723

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
  group1 ~~                                                                               
    group2           -0.333    0.058   -5.746    0.000   -0.446   -0.219   -1.000   -1.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
   .mtld            117.467   12.179    9.645    0.000   93.597  141.336  117.467    0.464
   .vocd            441.755   45.631    9.681    0.000  352.320  531.190  441.755    0.480
   .ndwerz            1.264    0.131    9.663    0.000    1.007    1.520    1.264    0.472
   .ndwesz            2.078    0.215    9.645    0.000    1.656    2.501    2.078    0.465
   .mattr             0.002    0.000    9.645    0.000    0.002    0.003    0.002    0.464
   .hdd               0.002    0.000    9.657    0.000    0.002    0.002    0.002    0.469
   .logttr            0.002    0.000    9.638    0.000    0.001    0.002    0.002    0.461
   .rttr              2.421    0.251    9.635    0.000    1.928    2.913    2.421    0.460
   .uber              2.042    0.212    9.634    0.000    1.627    2.457    2.042    0.460
   .lv                0.002    0.000    9.654    0.000    0.002    0.003    0.002    0.468
   .nv                0.002    0.000    9.681    0.000    0.002    0.002    0.002    0.480
   .vv1               0.003    0.000    9.675    0.000    0.002    0.003    0.003    0.477
   .vv2               0.003    0.000   10.162    0.000    0.002    0.003    0.003    0.860
   .cvv1              0.024    0.003    9.655    0.000    0.019    0.029    0.024    0.469
   .adjv              0.002    0.000    9.671    0.000    0.001    0.002    0.002    0.475
   .ld                0.003    0.000   10.192    0.000    0.002    0.003    0.003    0.904
   .ls1               0.003    0.000   10.056    0.000    0.002    0.003    0.003    0.766
   .ls2               0.002    0.000    9.292    0.000    0.002    0.002    0.002    0.481
   .vs2               0.184    0.020    9.286    0.000    0.145    0.223    0.184    0.480
   .cvs1              0.015    0.002    9.273    0.000    0.012    0.019    0.015    0.477
    group1          135.445   22.241    6.090    0.000   91.853  179.037    1.000    1.000
    group2            0.001    0.000    3.634    0.000    0.000    0.001    1.000    1.000

> lavInspect(fit2F, "cov.lv")
       group1  group2 
group1 135.445        
group2  -0.333   0.001

Thanks to all,
Maryam

ya

unread,
Mar 26, 2019, 8:36:52 PM3/26/19
to lav...@googlegroups.com
Dear list,

I am having trouble making a two-indicator measurement model identified. The code looks like below, but the output shows that the two indicators still have different loadings. What is the right way to do it? Thank you very much.


> library(lavaan)
> mod='xtyy=~NA*xtyy1+equal(xtyy=~xtyy1)*xtyy2;xtyy~~1*xtyy'
> fit=sem(mod,dat)
Warning message:
In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, :
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.


Latent Variables:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
xtyy =~
xtyy1 0.710 NA 0.710 0.771
xtyy2 (xty1) 0.402 NA 0.402 0.323




Best,

Y.A.

Edward Rigdon

unread,
Mar 26, 2019, 9:00:59 PM3/26/19
to lav...@googlegroups.com
Try this:
> mod='xtyy=~a*xtyy1+a*xtyy2
    xtyy~~1*xtyy'  
If lavaan wants to set a to 1, then try this:
> mod='xtyy=~NA*xtyy1+a*xtyy1+a*xtyy2
    xtyy~~1*xtyy'  

Yes, you can reference the same variable twice on the same line of code, applying different modifiers each time.

--
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.

ya

unread,
Mar 27, 2019, 10:01:56 PM3/27/19
to lav...@googlegroups.com
It worked, this is quite convenient. Thank you very much Edward:)

Terrence Jorgensen

unread,
Mar 29, 2019, 6:51:53 AM3/29/19
to lavaan
warning that "covariance matrix of latent variables is not positive definite" and I used lavInspect(fit, "cov.lv") with results that I show below; but when I checked goodness-of-fit indices, they all show very good fit.

Then it might just be sampling error.  You can see the problem in the "Std.all" column, where the latent variables are perfectly negatively correlated (with more decimals, you might see it is barely beyond -1, which would be impossible to observe in practice, but these are just estimates).

summary(fit2F, std=TRUE, nd = 5) # more digits

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

maryam nasseri

unread,
Mar 29, 2019, 7:07:20 AM3/29/19
to lav...@googlegroups.com
Hi Terrence

Thanks for your reponse. I found out that I made a mistake conducting that test.

cov.shrink() function should be applied to a data matrix; I have by mistake applied it to a covariance matrix and that's thevreason these strange results appeared. I corrected it and applied it to data matrix but model doesn't fit.

This was a L2 regularization method in the corpcor package, and then I used the output of it as the input to sem() function in lavaan so that I don't have to drop variables and loose information.

I'm not sure why the model still doesn't fit. I don't know if it's a case of multicollinearity or just a genuine misfit.

Thanks a lot again for your help

Maryam

--
Reply all
Reply to author
Forward
0 new messages