Bivariate ACE model fit causes R front-end shutdown

5 replies [Last post]
abhworthington's picture
Offline
Joined: 06/09/2010

Hello all,
I'm experiencing a somewhat frustrating error in an attempt to run some bivariate Cholesky ACE models using ordinal data. Rather than use raw data inputs (there are different numbers of thresholds across variables, so coding is tricky), I have taken the "easy" way and simply created polychoric correlation matrices for the variables of interest. However, when I attempt to fit the model, R crashes.
Now, I know that the term "crash" is not usually a preferred term here, but the Rgui program (on Windows here) shuts down without reporting an error within the program. The crash generates an error report, but sending to Microsoft won't really do anything. It appears to be a front-end crash.
I am currently running R 2.11.1 and the most current OpenMx.
I have replicated this on my work machine and my laptop, but lack the debugging skills to go much further. I have tried other code with the same form, but different values, and it runs just fine. So, I am confused as to why this set of parameters causes a crash in the fashion that it does, and what I can do to prevent this in the future (or at least to know how to get the kind of information I need from R to work it out myself). As always, many thanks for your help!
(I have attached the file as I last ran it.)

AttachmentSize
bivariate.cor_.testfile.R4.91 KB
abhworthington's picture
Offline
Joined: 06/09/2010
A Kludge?

If I change the negative correlations in both of the input matrices to positive correlations, the code runs just fine. Obviously, this isn't a real solution.

tbrick's picture
Offline
Joined: 07/31/2009
There are two problems

There are two problems here.

First, the model won't run because your MZ observed covariance matrix is non-positive-definite. Turning the negative covariance in the MZ matrix to a positive one makes the matrix positive definite, and lets the model run.

Covariance/correlation matrices from real data should always be positive definite. Unfortunately, polychoric correlation matrices especially tend to have the problem of coming out (incorrectly) non-positive definite if there's missingness and they're calculated pairwise. There was a question about this on the R-help forum a while back: you can find it on the R listserv archives here: http://tolstoy.newcastle.edu.au/R/e6/help/09/03/7663.html

Looks like the most recent response recommends the nearPD package in R, but maybe the folks who worked the answer out there can help more.

The second issue, of course, is that you've found a bug in OpenMx that's causing R to crash. Congratulations, and thanks! I think the error is actually in the error reporting for data matrices where type="cor". We'll get to work on fixing it, and we'll update this thread when the fix is ready.

You should be able to avoid the crash in the meantime by setting the data type to type="cov". Since a correlation matrix is just a covariance matrix of standardized values, your results should come out the same. Alternately, you should be fine running the model with type="cor" once you have the positive-definiteness issue worked out.

abhworthington's picture
Offline
Joined: 06/09/2010
Thanks for checking this out

Thanks for checking this out so quickly. I figured an NPD matrix was causing the issue (hence the kludge, which bypasses the entire issue), although switching to a covariance matrix doesn't solve the problem (I think I saw that elsewhere on the forums as a potential solution). Unfortunately, the crash prevented me from seeing errors, etc.

Glad to be a bug-hunter! Cheers on the nearPD link, will give it a good read and try that.

mspiegel's picture
Offline
Joined: 07/31/2009
I may not have access to a

I may not have access to a real computer (aka not an iPad) in the next few days. Someone should run the script using either valgrind or gdb.

mspiegel's picture
Offline
Joined: 07/31/2009
The error message you are

The error message you are supposed to be seeing is: "Observed Covariance Matrix is non-positive-definite." The message itself is not helpful, since I see that the data consists of correlation matrices.

Over the next few days we'll work on getting that message to the console instead of the current behavior, which is to segmentation fault.