Attachment | Size |
---|---|
OpenMX_code | 6.91 KB |
Allison et al. 2017 - ML for Cross-Lagged Panel Models with Fixed Effects | 776.15 KB |
Hey all,
I just started recently to use OpenMx for academic reasons. I'm currently trying to reproduce the empirical example of the paper of Allison et al. 2017 in which they use a Maximum Likelihood Structural Equation Model (ML-SEM) for dynamic panel models.
The authors provide the code of the following software packages: R-lavaan, Stata, Mplus, SAS-Proc Calis. However, I'm using OpenMx in R since it seems to be more flexible for changes and adjustments than lavaan.
You can find my code and the paper in the attachment. Unfortunately I get the following error message, but I can't find my error:
Error: The job for model 'Test1' exited abnormally with the error message: fit is not finite (The continuous part of the model implied covariance (loc2) is not positive definite in data 'Test1.data' row 499.
However, even if I delete row 499, the error remains. I hope that someone here in the forum can help me. Thank you very much in advance!
Welcome to OpenMx!
I don't see anything obviously wrong with your model specification, but there are a couple of standard things to check.
At the risk of being a bit pedantic, let me explain the error message. "fit is not finite": I tried to calculate the fit function value, but I got was infinity, negative infinity, or NA. "The continuous part of the model implied covariance is not positive definite": The model-implied covariance matrix is not acting like an actual covariance matrix. The "positive-definite" language is a generalization of the requirement that variances are always greater than zero (i.e., positive): by analogy, covariance matrices are always positive definite, but your model-implied covariance matrix appears not to be. Now, on to what you can do.
First, it looks like you're using the
haven
package to read in data. My experiences withhaven
have not been positive. Check to make surewages
is adata.frame
ormatrix
by runningis(wages)
. If not, you can useread.table()
instead ofhaven
, or cast it to adata.frame
withds <- as.data.frame(wages)
.Second, you can check the model-implied covariance matrix at the starting values with
Your starting values imply 11 zero eigenvalues and 5 negative ones. This is probably the issue. Set starting values (particularly variances) large enough that all the eigenvalues of the model-implied covariance matrix are positive. A built-in helper function for this is
mxAutoStart()
.Third, it looks like you have a free parameter named "ed" and also a variable named "ed". I don't know that this causes a problem or your problem, but it's probably not a good idea. Use a different variable name or free parameter label.
Fourth and finally, think about ways to make the model specification shorter and less tedious. This is just a style question. For example, many of the repeated paths in your script could be replaced with the following:
Cheers!
Dear Micheal Hunter,
thank you very much for your detailed answer. I'll check whether I can fix my problems with the help of your comments in the following days. Thanks a lot!
All the best to you!
Thanks again for your comment. I tried to solve the problem with the help of your instructions but unfortunately it didn't work. An updated version can be found attached ("TestOpenMx_new.R"). Among other things, I updated the starting parameters with regard to the suggestions produced by "mxAutoStart()" but, as I said, it still did not solve the problem. In order to approach to the core of the issue, I tried to estimate a short or reduced-version of my general model. But even that shows the same error message ("TestOpenMx_shortmodel").
Additionally, I converted the correct lavaan-Code, provided by the authors, by using the "metaSEM"-package into OpenMx. It produced some results but those results were completely different than the original results provided by lavaan. Do you have any ideas what could be the reason for this? I also attached this R-code ("lavaan.R").
Furthermore, I stumbled across the umx package. However, I can't find any explanations where exactly the difference to OpenMx is. Out of curiosity I tried the OpenMx script slightly modified with the umx package. However, this has also led to no positive result ("umx_new.R" - However, this might not be important right now). Maybe someone of you has experience with this and knows the difference to OpenMx?
I hope my explanations are not too excessive. Basically, I am trying to reproduce the paper pinned above with OpenMx. Since this doesn't work, I'm currently trying different possible solutions, but they don't currently lead to the right solution.
Hopefully, someone in this forum is able to help me to solve the issue. Many thanks in advance!
I plotted your model to take a look at it. I also had a look at the eigenvalues of the expected covariance matrix, like this:
which revealed a lot of negative eigenvalues. The diagram shows that there aren't residual variances on many of the variables. Changing starting values won't fix this problem.
require(umx); plot(model1)
I partly fixed it with making all variables have residual variances by replacing the few variables that did have residuals with the entire list of them. Then using mxTryHard() gets over the issue that these were all starting at zero. However, better is to explicitly tell it to start the residual variances at roughly the observed variances of the manifest variables, and to avoid giving the variables high covariances between them.
HTH!
Dear Michael Neale,
thank you very much for your helpful answer. It helped a lot to get rid of the error messages!
All the best to you!