You are here

Specifying Unique mxFitFunction

2 posts / 0 new
Last post
jacobucc's picture
Joined: 05/27/2014 - 17:18
Specifying Unique mxFitFunction
Binary Data openmx_q.R1.04 KB

I am new to 2.0 and am playing around with specifying a non-standard fit function, and have hit some road bumps in trying to start with specifying the ML fit through mxFitFunctionAlgebra. Attached is the reproducible script. Error message is:

Error: The job for model 'One Factor' exited abnormally with the error message: MxComputeGradientDescent: fitfunction One Factor.fitfunction is not finite ()

If mxFitFunctionAlgebra() is used, does it have to include a gradient specification?

Thanks for your help.
mx version 4157,R 3.1.2, Mac OSX.

mhunter's picture
Joined: 07/31/2009 - 15:26
Bound the variances

Gradient descent is the method of optimization used. The optimizer got into bad territory and then the fit function gave NaN. You don't have to provide a gradient. OpenMx computes it numerically.

To solve your issue, add a lower bound on the residual variances.

mxResVariances <-  mxMatrix(type="Diag", nrow=5, ncol=5,
                            free=TRUE, values=1, name="resVariances", lbound=1e-6)

The variances are becoming negative in the course of optimization, likely because the starting values are not great. With just adding the lower bound, I get a complete optimization but it does give a warning (MxStatus RED). Changing the starting values or re-running the model from the solution solved that.

mxFacLoadings  <-  mxMatrix(type="Full", nrow=5, ncol=1,
                            free=TRUE, values=0.8, name="facLoadings") #was.2
mxFacVariances <-  mxMatrix(type="Symm", nrow=1, ncol=1,
                            free=FALSE, values=1, name="facVariances")
mxResVariances <-  mxMatrix(type="Diag", nrow=5, ncol=5,
                            free=TRUE, values=.2, name="resVariances", lbound=1e-6) # was 1