You are here

help: "Cov" is not positive definite.

5 posts / 0 new
Last post
Kwabenaaaddo's picture
Joined: 02/01/2021 - 08:16
help: "Cov" is not positive definite.
Binary Data codes.R2.23 KB
File data.csv46.92 KB

Hello Mike,

Thank you for your awesome software. I have been working on a TSSEM and once I run my attached codes on the data in the excel file attached, I get the message below after the first stage regression is completed:

"Error in wls(Cov = pooledS, aCov = aCov, n = tssem1.obj$total.n, RAM = RAM, :
"aCov" is not positive definite.
In addition: Warning message:
In .solve(x = object$$calculatedHessian, parameters = :
Error in solving the Hessian matrix. Generalized inverse is used. The standard errors may not be trustworthy."

I have thoroughly checked my codes and data for possible errors but still can not resolve it. Could you please have a look and point out what could be the issue, please?

As a second issue, with similar data structure and codings, I am tried to run the TSSEM for a group of 14 variables. Again after the first stage output, the iterations/estimations for the second stage has been running for days with no output. Is this a normal thing or perhaps an issue of the low processing power of my computer?


AdminNeale's picture
Joined: 03/01/2013 - 14:09
Not enough data perhaps?

There used to be a rule of thumb for weighted least squares, I think from PRELIS/LISREL documentation, which recommended minimum sample size of about 200 times the number of variables. Having too little data could cause the problem you are reporting. Highly correlated variables may also generate non-positive definite asymptotic covariance matrices.

Possibly, things would go better with ML and robust standard errors, but I am not familiar with the levels of measurement of your variables.

For the job that has been running for days, try a different optimizer. If you have NPSOL enabled, then switching to it is easy by putting this line after loading the OpenMx library:

mxOption(NULL, 'Default optimizer', 'NPSOL)
Kwabenaaaddo's picture
Joined: 02/01/2021 - 08:16
Hello Neale,

Hello Neale,

Thanks for your suggestions. They were indeed helpful. Is they a way of testing/running/assessing a mediation analysis using the TSSEM, please?


Mike Cheung's picture
Joined: 10/08/2009 - 22:37
As Michael has said, the main

As Michael has said, the main reason is there is not enough data. There are only 3, 2, or even 1 data point in some cells. You may need to drop some variables before you can fit it. Another option is to apply a fixed-effects model if you can assume homogeneity of correlation matrices.

>, = FALSE)
DUA      46      21    18  17   7   5      2    1   34
BNKRISK  21     110    45  40   8  21     18    6   91
BSIZE    18      45   133  47  18  17     17    9  112
LEV      17      40    47 121  14  14     14    8   99
AGE       7       8    18  14  38   2      2    3   37
LIQ       5      21    17  14   2  51     10    2   42
OWNCON    2      18    17  14   2  10     43    1   35
INST      1       6     9   8   3   2      1   18   17
PERF     34      91   112  99  37  42     35   17  162

Regarding the mediation model, we may refer to the following pre-print.


Kwabenaaaddo's picture
Joined: 02/01/2021 - 08:16
Hello Mike,

Hello Mike,
Thank you very much for your suggestion. Really appreciated. I will give it a try.

Kindest Regards,