Problem instantiating an MxModel object using new()

Posted on
Picture of user. carey 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

Replied on Thu, 11/26/2009 - 12:48
Picture of user. mspiegel Joined: Jul 31, 2009

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.

Replied on Fri, 11/27/2009 - 10:57
Picture of user. carey Joined: Oct 19, 2009

In reply to by mspiegel

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

Replied on Fri, 11/27/2009 - 13:23
Picture of user. tbates Joined: Jul 31, 2009

In reply to by carey

"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.