In OpenMx 2, what does Error: no slot of name "objective" for this object of class "MxRAMModel" mean?

205 Views Asked by At

In OpenMx 1, we could access the objective with

model@objective

In OpenMx 2, this slot is missing (as the objective now distinguishes explicitly between the expectation and the fit function). So, I guess we should be accessing the objective with

model$expectation
model$fitfunction

Or

model@expectation
model@fitfunction

Is that right?

2

There are 2 best solutions below

0
On

Yes: in OpenMx 2 the correct thing to do is model$fitfunction and model$expectation

In general, in OpenMx 2, avoid using @ to access any part of a model: Use $ instead. Helpfully, OpenMx 2 also enables tab-completion for easy discovery of model components.

0
On

The 2.0 release note says:

  • Replacement of @ accessors with $ accessors in mxModel objects. You no longer have to keep track of when to use which; just always use $!

NOTE: Concerning the last bullet point, users should definitely get into the habit of ALWAYS using $ instead of @. For example, myModelRun@output$estimate would now be myModelRun$output$estimate. We CANNOT guarantee that every usage of the @ accessor that worked with versions 1.3/1.4 will continue to work in 2.0.

http://openmx.psyc.virginia.edu/2014/05/first-openmx-20-beta-released