You are here

How to use "mxFitFunctionAlgebra" instead of "mxAlgebraObjective"

4 posts / 0 new
Last post
rabil's picture
Offline
Joined: 01/14/2010 - 16:47
How to use "mxFitFunctionAlgebra" instead of "mxAlgebraObjective"

This code used to work using "mxAlgebraObjective", but now says I have to use "mxFitFunctionAlgebra" instead of "mxAlgebraObjective".

#

models_1_v4 <- mxModel("Models_1",
Model_1_t1_v4,
Model_1_t2_v4,
mxAlgebra(
Model_1_t1_v4.objective+
Model_1_t2_v4.objective,
name="multi"),

mxAlgebraObjective("multi"),

mxFitFunctionAlgebra(algebra = "multi")

)

m1_fit_v4 <- mxRun(models_1_v4)

#

I tried changing ".objective" to ".fitfunction" but this did not work either. What am I doing wrong?

AdminRobK's picture
Offline
Joined: 01/24/2014 - 12:15
I believe .objective still

I believe .objective still works. Give that a try.

Also, consider using mxFitFunctionMultiGroup() instead of an algebra fitfunction for this kind of thing.

rabil's picture
Offline
Joined: 01/14/2010 - 16:47
Thanks. I figured out what

Thanks. I figured out what was wrong. I was using the wrong names for the sub-models.

Is it possible to use mxFactorScores with the higher level model - that is, the model containing the submodels?

AdminHunter's picture
Offline
Joined: 03/01/2013 - 11:03
If you use multigroup ...

One benefit of the mxFitFunctionMultigroup() is that is allows you, in many cases, to get the factor scores from a multigroup model. It gives you a list of factor scores arrays. Each element of the list corresponds to one of the groups.

See this: https://github.com/OpenMx/OpenMx/blob/master/inst/models/nightly/FactorScores.R#L191-L209