# OpenMx Does Not Provide Correct Results for Example Code?

Here is the example code from mxTryHard:

library(OpenMx)

```
```data(demoOneFactor) # load the demoOneFactor dataframe

`manifests <- names(demoOneFactor) # set the manifest to the 5 demo variables`

latents <- c("G") # define 1 latent variable

model <- mxModel(model="One Factor", type="RAM",

manifestVars = manifests,

latentVars = latents,

mxPath(from=latents, to=manifests, labels=paste("b", 1:5, sep="")),

mxPath(from=manifests, arrows=2, labels=paste("u", 1:5, sep="")),

mxPath(from=latents , arrows=2, free=FALSE, values=1.0),

mxData(cov(demoOneFactor), type="cov", numObs=500)

)

model <- mxTryHard(model) # Run the model, returning the result into model

summary(model) # Show summary of the fitted model

Here are the results:

> model <- mxTryHard(model) # Run the model, returning the result into model

```
```Begin fit attempt 1 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 2 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 3 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 4 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 5 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 6 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 7 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 8 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 9 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 10 of at maximum 11 tries

Fit attempt generated errors

Begin fit attempt 11 of at maximum 11 tries

Fit attempt generated errors

`Retry limit reached`

All fit attempts resulted in errors - check starting values or model specification

I tried this several times with the same results.

Now I just ran it again in the same session and I get what I think are the correct results.

The problem is, when I run my real model under 15.04 on the other computer, I get entirely reasonable results with confidence intervals. When I run it under 16.04 on this computer, all I get are error messages or if I ask for confidence intervals the code runs but never appears to finish.

The problem with 16.04 has been going on for months so I had switched to the other computer. I tried again by re-installing or installing the latest version on the 16.04 computer but OpenMx still seems to be broken under 16.04.

## Start values need to be better now

It's not just ubuntu, same on all platforms. The issue is that the default start values are too far from the solution for some optimizers.

SLSQP solves the problem with no error, NPSOL solves with a code green, CSOLNP needs better start values.

I think the front page will likely be updated with a version starting the residuals at 1 and the paths from the latent variable at .2 or so.

A distinct issue is that code Red is much more common in newer versions of OpenMx. So even with good starting values, you may find code Reds.

Please let us know if the start values help.

PS: It's always helpful to append the results of

`mxVersion()`

: to queries like this.PPS:

`umxRAM`

picks nice starting values for models. You can use this directly with`umxValues()`

PPPS: A nice new OpenMx function will be of help soon in cases like this

`m1 = mxAutoStart(m1)`

Log in or register to post comments

## Thanks! I understand what you

Log in or register to post comments

## try again now

Log in or register to post comments

In reply to try again now by jpritikin

## All 3 optimisers same solution on Mac at least. one code red

|name | Std.Estimate| Std.SE|CI |

|:----|------------:|------:|:-----------------|

|b1 | 0.89| 0.01|0.89 [0.87, 0.91] |

|b2 | 0.93| 0.01|0.93 [0.92, 0.95] |

|b3 | 0.94| 0.01|0.94 [0.93, 0.95] |

|b4 | 0.96| 0.00|0.96 [0.95, 0.97] |

|b5 | 0.97| 0.00|0.97 [0.97, 0.98] |

|u1 | 0.21| 0.02|0.21 [0.17, 0.24] |

|u2 | 0.13| 0.01|0.13 [0.11, 0.15] |

|u3 | 0.11| 0.01|0.11 [0.09, 0.13] |

|u4 | 0.07| 0.01|0.07 [0.06, 0.09] |

|u5 | 0.05| 0.01|0.05 [0.04, 0.07] |

| | 1.00| 0.00|1 [1, 1] |

[1] "χ²(5) = 7.39, p = 0.193; CFI = 0.999; TLI = 0.999; RMSEA = 0.031"

Log in or register to post comments