how to test is a model is a RAM model
Posted on

Forums
The new 2-part objectives in OpenMx mean an older method for testing if a model is a RAM model don't work
I used to say this:
(isS4(obj) && is(obj, "MxModel") && class(obj$objective)[1] == "MxRAMObjective")
What code do people recommend for backward (and preferably forward compatible testing of model type? Do we need to add a type= field to MXModel?
best, tim
Haven't gotten this far in
Haven't gotten this far in the Expectation/Fit split, but it'll likely be as simple as replacing references to objective to references to expectation. I'll look into this more as we get closer to beta release.
Log in or register to post comments
In reply to Haven't gotten this far in by Ryne
omxModelType()
maybe an OpenMx supported function to maintain a robust backward compatible test for users. Perhaps allowing
omxModelType <- function(obj, typeList= (c("RAM", "LISREL", "MATRIX"){
# test each requested item
}
# typically called with one test case
if(omxModelType(m1, "RAM"){
}
Log in or register to post comments
In reply to omxModelType() by tbates
Your same code would work if
Your same code would work if you replace $objective with $expectation, and "MxRAMObjective" with "MxExpectationRAM". I'm not sure if that's the best practice, but it would work currently.
Log in or register to post comments
In reply to Your same code would work if by mhunter
old | new
this fails for current OpenMx.
class(obj$expectation)[1] == "MxExpectationRAM"
so the "good today, great tomorrow" test is
isModel = isS4(obj) & is(obj, "MxModel")
isRAM_Model = (class(obj$objective)[1] == "MxRAMObjective" | class(obj$expectation)[1] == "MxExpectationRAM")
isModel & isRAM_Model
:-)
Log in or register to post comments
In reply to old | new by tbates
This passes with the current
This passes with the current *source* build.
(isS4(obj) && is(obj, "MxModel") && class(obj$expectation)[1] == "MxExpectationRAM")
where obj is a fitted OpenMx model. I used demo/LatentGrowthCurveModel_PathRaw.R as a test case.
source("demo/LatentGrowthCurveModel_PathRaw.R")
obj <- growthCurveFit
(isS4(obj) && is(obj, "MxModel") && class(obj$expectation)[1] == "MxExpectationRAM")
Log in or register to post comments