mxTryHard status codes

Posted on
No user picture. Rachel Joined: 02/08/2012
Dear all,

I have been running a model within a loop over several variables, which does not converge well for all variables. Therefore, I applied mxTryHard. There are two things I noticed:

1) for models that run well without calling mxTryHard the best fit does not seem to change using mxTryHard, but the status code changes from 0 to -1

> fit1 <- mxRun(model,intervals =F)
> fit1$output$Minus2LogLikelihood
[1] 4595.342
> fit1$output$status
$code
[1] 0
$status
[1] 0

fit2<-mxTryHard(model,intervals=F)
> fit2$output$Minus2LogLikelihood
[1] 4595.342
fit2$output$status
$code
[1] -1

$status
[1] 0

2) even when I set "intervals=F" (like in the example above) the mxTryHard option computes intervals.

Can you help?
Thanks in advance

Replied on Wed, 09/16/2015 - 06:47
No user picture. CharlesD Joined: 04/30/2013

Thanks Rachel. The first bug you mention should already be resolved in the development version of OpenMx. The second is a good point, I will adjust this. These changes will be available in the next release, or by building OpenMx from source.
Replied on Sun, 11/15/2015 - 15:52
No user picture. martonandko Joined: 02/19/2015

Hi all,

I experience the same status code = -1 problem in case of any model I run with mxTryHard, be it a model that results in "Solution found", or a model that results: "OpenMx status code 1 greater than 0; Not all eigenvalues of hessian are greater than 0; Retry limit reached, "

I'm running OpenMx version: 2.3.1 [GIT v2.3.1], R version: R version 3.2.1 (2015-06-18), Platform: x86_64-w64-mingw32, Default optimiser: NPSOL, installed from the website.

Does this mean both models converged (MxStatus Green)?

Replied on Mon, 11/16/2015 - 12:51
Picture of user. AdminRobK Joined: 01/24/2014

In reply to by martonandko

Status code = -1 means premature termination of the optimizer, so I don't think any models converged. Based on the information in your post, I'm not sure what's going on, though. Could you copy-paste the messages printed to the screen by mxTryHard()?
Replied on Mon, 11/16/2015 - 13:15
No user picture. martonandko Joined: 02/19/2015

In reply to by AdminRobK

Thanks for having a look at it!

Limiting the extra runs to 1 to supress output (output the same for 10 extra runs), mxTryHard returns:

Begin fit attempt 1 of at maximum 2 tries

Lowest minimum so far: 461.211751950297

Not all eigenvalues of hessian are greater than 0: 559.193020473922, 486.393117628652, 204.302637390566, 187.97870749209, 174.565171935069, 127.448215232486, 34.6394063711714, 4.85183481710131, 1.37182372473253, -0.127544032337779

Begin fit attempt 2 of at maximum 2 tries

Lowest minimum so far: 461.211751950279

OpenMx status code 1 greater than 0

Not all eigenvalues of hessian are greater than 0: 559.192121639248, 486.392579488029, 204.304599125184, 187.979472270581, 174.565930769942, 127.448041794442, 34.6396697751378, 4.8521695638418, 1.37244146991232, -0.126964546464526

Retry limit reached
Estimate confidence intervals for imperfect solution

Start values from best fit:
0.767557125047236,0.169527920231489,0.414497889243009,0.543614188916936,0.728527002372227,0.505322379565154,0.118637216479181,-0.0932594170628762,1,1

@output$status returns:

$code
[1] -1

$status
[1] 0

In case of a model where it says, solution found:

Begin fit attempt 1 of at maximum 11 tries

Lowest minimum so far: 461.211751950294

OpenMx status code 1 greater than 0

Begin fit attempt 2 of at maximum 11 tries

Lowest minimum so far: 461.211751950276

OpenMx status code 1 greater than 0

Begin fit attempt 3 of at maximum 11 tries

Lowest minimum so far: 461.211751950274

Solution found

Estimating confidence intervals

Start values from best fit:
0.767557199351073,0.169527720018016,0.414497827985777,0.543614118267592,0.728526940730898,0.505322361547715,0.11863739923075,-0.0932593099645859,1

But the status is the same as the previuos model:

$code
[1] -1

$status
[1] 0

Replied on Tue, 11/17/2015 - 17:33
No user picture. martonandko Joined: 02/19/2015

In reply to by AdminRobK

Thanks for the information! mxTryHard really seems like a nice tool, hope the bug can be fixed easily. Is there a way to identify mxTryHard runs which terminate with a solution, other than the status code for the time being?

Two other interesting things, which might be bugs is:
-if I rerun a fitted model, which was fitted with mxTryHard with the simple mxRun command, the status code stays -1 for all models.
-if I don't include the "intervals = T" command in the mxTryHard command, and rerun the fitted model with the simple mxRun command with the "intervals = T" command, then it doesn't calculate the confidence intervals.

Replied on Wed, 11/18/2015 - 05:20
No user picture. CharlesD Joined: 04/30/2013

In reply to by martonandko

Thanks for pointing these out, they all stem from the one issue which needs to be fixed really. For the moment, a work around would be to use omxGetParameters() to extract the estimates from the mxTryhard with intervals=F solution, and omxSetParameters() to assign these values to an unfitted model, then fit this with mxRun and intervals=T. Or just pay attention to whether mxtryhard reports 'solution found' or not - this indicates that the fit prior to estimating confidence intervals was accepted, and confidence interval estimation won't change this. Sorry for the fuss! :)