lavaan ERROR: sample covariance matrix is not positive-definite

116 views
Skip to first unread message

Jade Ding

unread,
Jan 16, 2019, 2:09:36 AM1/16/19
to lavaan
I am using lavaan for a model I created:

mod.3 <-'
s_cred ~ Med_Alg
s_cred ~ Med_Mdia
s_cred ~ Med_Fact
s_cred ~ Med_Uni
s_exp ~ Med_Alg
s_exp ~ Med_Mdia
s_exp ~ Med_Fact
s_exp ~ Med_Uni
m_credibility ~ s_cred + s_exp
post_att ~ m_credibility
s_cred ~~ s_exp
'

fit.mod.3 <-sem(mod.3, data = fact_pass1, std.lv = TRUE, missing = "fiml")
summary(fit.mod.3, standardized = TRUE, fit.measures = TRUE, rsquare = TRUE)

I got the error: 
Error in lav_samplestats_icov(COV = cov[[g]], ridge = ridge, x.idx = x.idx[[g]],  : 
  lavaan ERROR: sample covariance matrix is not positive-definite

I checked the sample covariance matrix:
             [,1]        [,2]        [,3]         [,4]         [,5]         [,6]         [,7]        [,8]
[1,]  1.692791957 -0.10917026 -0.21861477 -0.234459695 -0.009085666  0.028148062  0.009349616 -0.02841201
[2,] -0.109170265  2.22850978  1.29626675  0.710606040 -0.016972996 -0.129350567 -0.041114109  0.18743767
[3,] -0.218614775  1.29626675  2.80818255  1.150875217 -0.018927323 -0.026051670 -0.025861506  0.07084050
[4,] -0.234459695  0.71060604  1.15087522  2.662285491 -0.004239921 -0.008223286 -0.015055770  0.02751898
[5,] -0.009085666 -0.01697300 -0.01892732 -0.004239921  0.094536038 -0.030570077 -0.030826969 -0.03313899
[6,]  0.028148062 -0.12935057 -0.02605167 -0.008223286 -0.030570077  0.205557417 -0.084331248 -0.09065609
[7,]  0.009349616 -0.04111411 -0.02586151 -0.015055770 -0.030826969 -0.084331248  0.206576125 -0.09141791
[8,] -0.028412012  0.18743767  0.07084050  0.027518977 -0.033138992 -0.090656092 -0.091417908  0.21521299

I don't know how to solve this problem, does anyone have any ideas?

Terrence Jorgensen

unread,
Jan 16, 2019, 6:16:36 PM1/16/19
to lavaan
fit.mod.3 <-sem(mod.3, data = fact_pass1, std.lv = TRUE, missing = "fiml")
Error in lav_samplestats_icov(COV = cov[[g]], ridge = ridge, x.idx = x.idx[[g]],  : 
  lavaan ERROR: sample covariance matrix is not positive-definite

I can only guess that the estimated covariance matrix is NPD because there is a lot of missing data.  I'm not sure there is a solution if FIML cannot find a proper solution when fitting the saturated (h1) model.  You could try using multiple imputation instead, but I'm not sure the same problem wouldn't manifest as the pooled (i.e., average) sample covariance matrix being NPD.

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

Reply all
Reply to author
Forward
0 new messages