[R] Lavaan: Immediate non-positive definite matrix

Joshua Wiley jwiley.psych at gmail.com
Fri Aug 10 22:17:28 CEST 2012


Dear Andrew,

Maximum likelihood estimation with missing data typically makes some
rather strong assumptions.  If I am not mistaken, the default
covariance coverage in Mplus is .05, the fact that you need to set it
lower suggests you have some combinations of variables with less than
5% jointly present?

If that is true, I am not surprised you are getting errors.
Estimation is an iterative process utilizing the expectation
maximization algorithm with the E step finding the expected value
given the available data and then maximizing the parameters based on
that, which becomes the basis for another E step and so on.  In the
case of no missing data, the expectations do not need to be updated at
all (easy) in the case of a lot of missing data, more steps are
required.  With < 5% (if the assumptions that conclusion was
predicated on are indeed true) pairwise present data for some
combinations, estimates could be quite instable.

If you are dealing with a typical longitudinal study, drop out
probably increases with each additional time point.  The easiest case
is where dropout is monotonic, in which case perhaps it still makes
sense to try to include all time points.  If the missingness is not
monotonic and the < 5% is with some combination of the final time
point, I would suggest you simply look at an unconditional growth
model of say the first 5 or 6 time points.

Actually, even if you keep all 7, if there is increasing missingness
at later time points, I would suggest that you try just 5 and 6 times
as a sort of sensitivity analysis to see how your results are
effected.

I realize that none of my comments really directly pertain to R so
this email is rather off topic for R help.  Here is my saving bit ;)
For data, try sharing it by uploading to some website such as google
drive, dropbox, skydrive, etc. and then just sharing a link with your
emails.  Also, while you're at that, perhaps include the R script to
read data in and load lavaan etc.

>From my brief read of the lavaan error message, it suggests that the
sample covariance matrix is not positive definite and not invertible
(well, I am assuming that S standards for the sample covariance
matrix).

Can you try fitting the model with listwise deletion and with direct
ML?  Have you look at the (listwise) present sample covariance matrix?
 Finally, you could try fitting the model in OpenMx, which also runs
in R.

Cheers,

Josh


On Fri, Aug 10, 2012 at 12:27 PM, Andrew Miles <rstuff.miles at gmail.com> wrote:
> Hi,
>
> I recently tried to estimate a linear unconditional latent growth curve on
> 7 repeated measures using lavaan (most recent version):
>
> modspec='
>
> alpha =~ 1*read_g0 + 1*read_g1 + 1*read_g2 + 1*read_g3 + 1*read_g4 +
> 1*read_g5 + 1*read_g6
>
> beta =~ 0*read_g0 + 1*read_g1 + 2*read_g2 + 3*read_g3 + 4*read_g4 +
> 5*read_g5 + 6*read_g6
>
> '
>
> gmod=lavaan(modspec, data=math, meanstructure=T, int.ov.free=F, int.lv.free=
> T, auto.var=T, auto.cov.lv.x=T, auto.cov.y=T, missing="direct", verbose=T)
> The model immediately returned the following error message:
>
> Error in chol.default(S) :
>
>   the leading minor of order 5 is not positive definite
>
> Error in lavSampleStatsFromData(Data = lavaanData, rescale =
> (lavaanOptions$estimator ==  :
>
>   lavaan ERROR: sample covariance can not be inverted
> I ran the same model in Mplus and found that it has low covariance coverage
> for the 7 repeated measures, but all coverage is greater than 0.  The model
> ran fine in Mplus once I set the covariance coverage limit to .001.  That
> provided me starting values to try in lavaan, but again it immediately
> returned the same error message.  In fact, nothing I could do allowed me to
> fit the model without it immediately returning the same error message
> (e.g., I tried changing the optimizer, the type of likelihood being used).
>
> Because the error message pops up immediately (i.e., not after lavaan tries
> to estimate the model for a few seconds), it makes me think that my data is
> failing some sort of initial data check.
>
> Any ideas what is happening, or what to do about it?  Thanks.
>
> P.S.  I haven't had success in attaching data files when I submit to the R
> help list, so if you would like the data please email me at
> andrewamiles at hotmail.com.
>
> Andrew Miles
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/



More information about the R-help mailing list