Hi All,
I am having an issue with the mxConstraint command.
I am getting an error when I try and constrain the sum of the squared real and imaginary eigenvalues to be less than a unit matrix.
The algebra and constraint commands are:
mxAlgebra( expression=(eigenval(ACE.bm)^2) + (ieigenval(ACE.bm)^2), name="eigen"),
mxMatrix( type="Full", nrow=2, ncol=1, free=FALSE, values= 1, name="unit"),
mxConstraint(eigen
Sorry, just noticed that the commands didn't post properly
Here they are again,
Thanks
Try using mxEval(...,compute=TRUE) to confirm that the left-hand side of the constraint is a 2 x 1 matrix.
So for example, use something like:
mxEval(eigenval(ACE.bm)^2 + ieigenval(ACE.bm)^2, model, compute=TRUE)
When I use the command you suggested I get a 2 x 1 matrix:
> mxEval(eigenval(ACE.bm)^2 + ieigenval(ACE.bm)^2, bivHetACEDualFit , compute=TRUE)
[,1]
[1,] 1.024890
[2,] 1.024890
That sounds like a bug. Can you attach a script that reproduces the behavior? Use the fakeData() function to generate synthetic data: http://openmx.psyc.virginia.edu/wiki/generating-simulated-data
I am attaching a copy of two fake data files (for each group) and the script with the "problematic" equality constraint.
Thanks for any help you may be able to supply.
Brad
Aha. I'm very sorry about this bug. Here is the short explanation. Replace your 'eigen' algebra with the following and it will work:
Here is the long explanation. The OpenMx backend is a matrix processing language. We have two types of exponent operators '^' and '%^%'. The first operator performs element-wise exponentiation. Both arguments must be of the same dimensions. The second operator performs a kronecker-exponentiation. This is similar to kronecker multiplication, but with the exponent operator instead of the multiplication operator.
The OpenMx frontend performs all the error checking in R. The '^' operator in R does element-wise exponentiation when the two arguments are matrices of the same dimension, and kronecker exponentiation when the second argument is a scalar value. In the past, we have manually caught and reported meaningful errors when the R semantics and OpenMx backend semantics did not agree. This is one case that we forgot.
Thanks, that seems to have worked.
Just a heads up, I'm checking in a patch to clean up one of the dark corners of error checking. This patch will eventually make itself into the OpenMx 1.1 release. The new error message for this script will be:
Error: The following error occurred while evaluating the subexpression 'eigenval(ACE.bm)^
2
' during the evaluation of 'ACE.eigen' in model 'bivHetACE' : non-conformable arrays.