Problem instantiating an MxModel object using new()

3 replies [Last post]
carey's picture
Offline
Joined: 10/19/2009

again, pardon intrusions from an R neophyte.

# this works
thisOMxModel <- mxModel("thisOMxModel", mxMatrix(name='VA', type='Symm', free=TRUE, nrow=8, ncol=8) )

# but this does not
thatOMxModel <- new("MxModel")
thatOMxModel <- mxModel(thatOMxModel, mxMatrix(name='VA', type='Symm', free=TRUE, nrow=8, ncol=8) )

greg

mspiegel's picture
Offline
Joined: 07/31/2009
Ah. The problems occurs

Ah. The problems occurs because thatOMxModel has a name argument of character(). Until recently there was an implicit restriction that named entities could not have a name of length 0. This restriction was made explicit in subversion revision 987. We recommend using the mxModel, mxAlgebra, mxMatrix, etc. interface functions instead using the S4 constructors directory. The constructors do not perform any error checking.

carey's picture
Offline
Joined: 10/19/2009
thanks, that explains it,

thanks,
that explains it, although i am clueless as to what subversion revision 987 means.

i can see user problems, however, with the interface between R and OpenMx when ordinary R functions give inconsistencies from mxXXX functions which, in turn can give inconsistencies within themselves. consider the "name argument" mentioned above above. try

A <- mxModel(model="B", name="C")
A@name
D <- mxModel(name="E")
D@name

tbates's picture
Offline
Joined: 07/31/2009
"subversion revision 987"

"subversion revision 987" refers to the build (# 987) of OpenMx in which this was fixed.

this line
A <- mxModel(model="B", name="C")

is saying "make a new model with name "B" and name "C" "

Perhaps that should throw an error, but I am not sure many people will try and do that: You only pass a string in as the first parameter to set the name of the new model, you only use name to create a new name when the first parameter was a base model being passed in.