Published on *OpenMx* (http://openmx.psyc.virginia.edu)

By *neale*

Created *07/02/2011 - 07:54*

Sat, 07/02/2011 - 07:54 — neale [1]

So I am familiar with being able to refer to an MxModel object, and in particular its objective function, by name, thusly:

algObj <- mxAlgebra(-2*sum(log(classProbs[1,1]%x%Class1.objective + classProbs[2,1]%x%Class2.objective)), name="mixtureObj")

where Class1 and Class2 are models, and their vector=T (individual observation vector) likelihoods are returned in Class1.objective & Class2.objective vectors. However, I am trying to specify a model with hundreds of models, and it would be much more convenient to be able to refer to them by an array index variable, so that I could use something like

algObj <- mxAlgebra(-2*sum(log(classProbs[1,1]%x%submodels[1].objective + classProbs[2,1]%x%submodels[2].objective)), name="mixtureObj")

with a view to having a much simplified matrix algebra form for the -2lnL, constructed by, e.g., cbind'ing all the vector=TRUE'd likelihoods (not quite sure how to do this within mxAlgebra() either), and post-multiplying that matrix by the classProbs matrix.

I have a feeling I may be needing mxRowObjective() but perhaps someone else has tackled this problem?

**Links:**

[1] http://openmx.psyc.virginia.edu/users/neale

[2] http://openmx.psyc.virginia.edu/thread/1009

[3] http://openmx.psyc.virginia.edu/thread/996

[4] http://openmx.psyc.virginia.edu/forums/openmx-help/openmx-general-help