Can't figure this out - lavaan ERROR: initial model-implied matrix (Sigma) is not positive definite

3,177 views
Skip to first unread message

Jesse Fagan

unread,
Apr 1, 2014, 4:51:03 PM4/1/14
to lav...@googlegroups.com

I am trying to recreate this model result. 

It has 6 exogenous covariates, one latent variable, two covariances, and four variances (at least that's how I interpret it). I extracted the correlation matrix from the paper. Here is the R syntax I am using.

x.cor <- " 0.47
 0.15  0.09
-0.02  0.26  0.31
 0.14  0.16  0.08  0.13
-0.15 -0.04  0.11  0.04  0.61
 0.15  0.09 -0.16 -0.33  0.02 -0.07
 0.05  0.12  0.22  0.15  0.55  0.36 -0.25
-0.19  0.03 -0.03 -0.03 -0.06 -0.03  0.27 -0.02
 0.04  0.07  0.12 -0.04 -0.13 -0.10  0.10 -0.17 -0.01"


sds
<- c(0.63,0.53,0.59,0.51,0.48,0.61,4.31,3.60,2.17,0.51)

N
<- 55

nms
<- c('dadRateMomProblemSolving','dadRateYouthProblemSolving','momRateDadProblemSolving','momRateYouthProblemSolving','youthRateMomProblemSolving','youthRateDadProblemSolving','youthDelinquency','youthSelfesteem','youthAge','youthSex')

x
.cov <- getCov(x.cor, sds=sds, lower=T, diagonal=F,names=nms)

mod1
<- '
  # Latent variable
  famProbSolve =~ momRateYouthProblemSolving + dadRateYouthProblemSolving + momRateDadProblemSolving + dadRateMomProblemSolving + youthRateMomProblemSolving + youthRateDadProblemSolving
  # Covariances
  momRateYouthProblemSolving ~~ dadRateYouthProblemSolving
  youthRateMomProblemSolving ~~ youthRateDadProblemSolving
  # Variances
  momRateYouthProblemSolving ~~ momRateYouthProblemSolving
  dadRateYouthProblemSolving ~~ dadRateYouthProblemSolving
  youthRateMomProblemSolving ~~ youthRateMomProblemSolving
  youthRateDadProblemSolving ~~ youthRateDadProblemSolving'


m1
.fit <- lavaan(mod1, model.type='cfa', sample.cov = x.cov, sample.nobs = N, estimator='ML',
                 
fixed.x = F, auto.var=F)

parameterEstimates
(m1.fit, ci=T, boot.ci.type='norm')

fitMeasures
(m1.fit)


And when I run I get:

> m1.fit <- lavaan(mod1, model.type='cfa', sample.cov = x.cov, sample.nobs = N, estimator='ML', 
+                  fixed.x = F, auto.var=F)
Error in estimateModel(lavaanModel, samplestats = lavaanSampleStats, X = lavaanData@X,  : 
  lavaan ERROR: initial model-implied matrix (Sigma) is not positive definite;
  check your model and/or starting parameters.

Any thoughts? Thanks for any help you can give!

David Kaplan

unread,
Apr 1, 2014, 5:18:13 PM4/1/14
to lav...@googlegroups.com
This is a one factor model where you are allowing residuals to correlate.  Take out the residual correlations and see what happens.  If you still get the message, see if it will run as an EFA in a program like "fa" in the "psych" package.  One possibility is that you have a negative residual variance (a Heywood case).  If so, and with one factor, you have have some redundancies among your variables.

Good luck.

David

Edward Rigdon

unread,
Apr 1, 2014, 8:16:08 PM4/1/14
to lav...@googlegroups.com
Jesse.
I think the problem is in your variances.  You specified free residual variances for 4 indicators but not for the other 2.  And you set auto.var= F, so I don't think the common factor has a variance--which means Sigma must be not positive definite.  Change auto.var to T, or specify the additional variances.  But you also need to scale the factor, so you must either fix a loading (to 1, say) or fix the factor's variance.  the former is better, but for convenience, fox the factor's variance to 1 and try it again.
--Ed Rigdon

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

Jesse Fagan

unread,
Apr 2, 2014, 2:40:30 PM4/2/14
to lav...@googlegroups.com
I integrated your recommendations, but the model wouldn't converge. I had to modify the tolerance of the optimization. The results match those in the article. Thanks!

x.cor <- " 0.47
 0.15  0.09
-0.02  0.26  0.31
 0.14  0.16  0.08  0.13
-0.15 -0.04  0.11  0.04  0.61
 0.15  0.09 -0.16 -0.33  0.02 -0.07
 0.05  0.12  0.22  0.15  0.55  0.36 -0.25
-0.19  0.03 -0.03 -0.03 -0.06 -0.03  0.27 -0.02
 0.04  0.07  0.12 -0.04 -0.13 -0.10  0.10 -0.17 -0.01"

sds
<- c(0.63,0.53,0.59,0.51,0.48,0.61,4.31,3.60,2.17,0.51)

means
<- c(3.92,3.84,3.62,3.86,3.78,3.72,18.01,26.38,14.02,0.50)
N
<- 55
nms
<- c('dm','dy','md','my','ym','yd','youthDelinquency','youthSelfesteem','youthAge','youthSex')

x
.cov <- getCov(x.cor, sds=sds, lower=T, diagonal=F,names=nms)
mod1
<-
'
  # Latent variable
  famProbSolve =~ my + dy + md + dm + ym + yd
  # Fix variance of famProbSolve
  famProbSolve ~~ 1 * famProbSolve
  dm ~~ e1 * dm
  dy ~~ e2 * dy
  md ~~ e3 * md
  my ~~ e4 * my
  ym ~~ e5 * ym
  yd ~~ e6 * yd
'

rm
('m1.fit')
fitMeasures
(m1.fit <- lavaan(mod1, model.type='cfa', sample.cov = x.cov, sample.nobs = N, control=list(x.tol=1e-6),
                             estimator
='ML', fixed.x = F, auto.var=T))[c('chisq','df','pvalue','cfi')]

parameterEstimates
(m1.fit, ci=T, boot.ci.type='norm')
fitMeasures
(m1.fit)
Reply all
Reply to author
Forward
0 new messages