You are here

Error in .Internal(as.vector(x, "symbol")) : 'x' is missing

3 posts / 0 new
Last post
carey's picture
Offline
Joined: 10/19/2009 - 15:38
Error in .Internal(as.vector(x, "symbol")) : 'x' is missing
AttachmentSize
Binary Data weirdError.R1.15 KB

maybe it is too late at night, but am befuddled by this error message:

> model1 <- mxModel(model1,
+ mxAlgebra(name="fvalMZ", expression = weight * (MZ@data@observed - MZ$zpreMZ) *
+ (MZ@data@observed - MZ$zpreMZ)))
Error in .Internal(as.vector(x, "symbol")) : 'x' is missing

full code attached

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
Oops, my apologies. There was

Oops, my apologies. There was an error in our error handling! The error message should have been:

Unknown matrix operator or function '@' in mxAlgebra(name = "fvalMZ", expression = weight * (MZ@data@observed - MZ$zpreMZ) * (MZ@data@observed - MZ$zpreMZ))

There are two things going on here: the '@' operator is not allowed inside mxAlgebra() expressions. Inside a mxAlgebra(), it is legal to reference any MxMatrix or MxAlgebra by name, along with any combination of supported matrix operators or functions (see list). We also allow numeric literals and the names of free parameters in an MxAlgebra expression, but those are automagically translated into 1 x 1 matrices.

I think the more useful piece of advice is that if you'd like to evaluate an algebra that is based on data, the trick we use for now is to duplicate the contents of the data and place it inside a MxMatrix with an arbitrary name, like "matrixData" or something, with no free parameters.

I think you want to replace the '^' operator with the '%^%' operator. The former requires that the two arguments have equal dimensions, and the later does not. Thanks to R's misguided operator overloading, the '^' operator performs matrix exponentiation when both arguments are matrices, but it performs kronecker exponentiation when the second argument is a scalar value. Since in OpenMx everything is a matrix, you need to use the kronecker exponent to have the desired effect.

carey's picture
Offline
Joined: 10/19/2009 - 15:38
muchas gracias!

muchas gracias!