Hi,

It would be very helpful if the following can be done in OpenMx:

1. Evaluate (for all cases at once) an mxAlgebra that involves definition variables. I think currently one can only evaluate such an mxAlgebra for a single case.

2. Define an user specified objective function that is the sum of a casewise function of the data and parameters. I think currently the casewise function can be defined with definition variables, but is there a way to sum them?

3. Supply the gradients of the target function and constraints, and the approximate Hessian. I can see mxOption can change the option of NPSOL to accept user defined gradients and Hessian, but there seems no way to supply them.

Thanks.

Hao

You can use a wrapper function to evaluate an mxAlgebra across all rows. For example, assume I need to evaluate the algebra A + B + C, and my data set has N rows. Then I would use,

Thanks for the feedback!

Your request number 2 can be done with an mxRowObjective. Examples and details are at ?mxRowObjective, but it's essentially a map-reduce algebra. You specify an algebraic calculation to be performed at each row that must evaluate to a row matrix (so, the algebra might return a 1x2 matrix). Those results are aggregated into rows of an output matrix (in this case, Nx2), and a second algebra is performed on that matrix (easiest would be just a total sum).

Number 1 can be done either with a wrapper function (see Michael's answer) or as the first part of an mxRowObjective, as above.

User-specified gradients/hessians are on the to-do list, but had dropped lower on the list because (I think) the perception was that user interest was pretty low. As you mentioned, some of the scaffolding for it is already there, but there are some details (for example, the user-side interface) that still need to be worked out. But thanks for the request -- we'll bump the feature a bit higher up on the feature request list.

Thank you guys. Your solutions are very helpful.