I have had good experience with the Mx option THard=-n in Mx, also called Automatic Cold Restart. Is this option still available in OpenMx and, if not, why is it taken out?
Thanks for any answer in advance,
Han Oud

So help the discussion, here's the description of Mx option THard=-n:

During optimization, an estimate of the covariance matrix of the estimated parameters is constructed. Sometimes, this covariance matrix is inaccurate and optimization fails to converge to the correct solution, a problem that is usually flagged by an IFAIL parameter of 6. Option TH=-n can be used to restart the optimization n times from the current solution, but with the parameter covariance matrix reset to zero.

Can this functionality be replicated in R? Somebody more knowledgeable than I will hopefully answer this question.

You can replicate THard by re-running the fitted model

You can replicate THard by re-running the fitted model, if I understand the THard argument right (Mike N., correct me if I'm wrong on that). We start cold every time you re-run the model, so it should automatically reset the estimated covariance of the parameters.

A helper function can replicate this effect by just calling mxRun repeatedly on the model. Admittedly, there's some overhead involved in doing so, since the model has to be re-flattened and reprocessed by the back-end. If we want a full implementation of this, it should be done in the back-end for the sake of performance. We'll put the feature on the list and you can use the helper in the meantime.

The helper function would be something like this (sorry it's messy--this is off the top of my head).

tryHard
fit
while(fit@output$status[[1]] == 6 & n > 2) {
print(paste("Trying hard...", n-1, "more times."))
fit
n
}
fit
return(fit)
}

The last re-run includes the original arguments, so it will do things like calculate confidence intervals, etc.
There are a few cases where it'll run an extra time to calculate CIs, but if it's already converged, the last run should be quick.

So help the discussion, here's the description of Mx option THard=-n:

Can this functionality be replicated in R? Somebody more knowledgeable than I will hopefully answer this question.

You can replicate THard by re-running the fitted model, if I understand the THard argument right (Mike N., correct me if I'm wrong on that). We start cold every time you re-run the model, so it should automatically reset the estimated covariance of the parameters.

A helper function can replicate this effect by just calling mxRun repeatedly on the model. Admittedly, there's some overhead involved in doing so, since the model has to be re-flattened and reprocessed by the back-end. If we want a full implementation of this, it should be done in the back-end for the sake of performance. We'll put the feature on the list and you can use the helper in the meantime.

The helper function would be something like this (sorry it's messy--this is off the top of my head).

tryHard fit while(fit@output$status[[1]] == 6 & n > 2) {

print(paste("Trying hard...", n-1, "more times."))

fit n }

fit return(fit)

}

The last re-run includes the original arguments, so it will do things like calculate confidence intervals, etc.

There are a few cases where it'll run an extra time to calculate CIs, but if it's already converged, the last run should be quick.

Presumably you'd want to turn off the numerical Hessian for all iterations but the last, as there's no need for that overhead.

Thanks, Timothy, for helping with tryHard. I had a try but did not get any relevant output. Did I do something wrong? See below input and output.

tryHard + fit + while(fit@output$status[[1]]==6 & n>2){

+ print(paste("Trying hard...",n-1, "more times."))

+ fit + summary(fit)

+ n + }

+ return(fit)

+ }

>

> model > n > tryHard(model,n)

Running LatDepModelUn

MxModel 'LatDepModelUn'

type : default

@matrices : 'A', 'S', 'F', and 'M'

@algebras :

@constraints :

@intervals :

@latentVars : none

@manifestVars : none

@data : 49 x 10

@data means : NA

@data type: 'raw'

@submodels :

@objective : MxRAMObjective

@independent : FALSE

@options :

@output : TRUE

>

try this instead of your tryHard line

LatDepModelUn summary(LatDepModelUn)

Thanks Timothy and Timothy. It seems to work. Best, Han