remove = TRUE issue
Posted on

Forums
try the following code
VA <- mxMatrix(name="VA", type="Symm", nrow=5, ncol=5)
DZ <- mxAlgebra(.5 %x% VA, name="covDZA")
test <- mxModel(model="test", VA, DZ )
test
names(test)
rm1 <- mxModel(test, test@matrices$VA, remove=TRUE)
rm2 <- mxModel(test, test@algebras$covDZA, remove=TRUE)
rm3 <- mxModel(test, test@algebras$DZ, remove=TRUE)
why doesn't remove=TRUE work with rm1 and rm2 while it fails to throw an error or warning with rm3?
thought that this was sorted out. see http://openmx.psyc.virginia.edu/thread/269
This looks like one big bug
This looks like one big bug and one small bug. The remove=TRUE should work on rm1 and rm2. I'm getting an internal error message when I try it, which is bad. I'll fix it. We'll release OpenMx 1.0.4 in a few days with this patch. In the construction of rm3, the expression test@algebras$DZ yields NULL. This is the small bug. It's unclear whether adding or removing NULL from a model should either (a) return the original model, the current behavior, or (b) throw an error. I'm in favor of throwing an error.
Log in or register to post comments
In reply to This looks like one big bug by mspiegel
In the meantime, you can
In the meantime, you can use:
rm1 <- test
rm1$VA <- NULL
But I'll fix it shortly.
Log in or register to post comments
OK I've checked in a patch to
OK I've checked in a patch to fix the more significant issue. The original behavior of the argument remove = TRUE was for the function mxModel() to accept character strings instead of the objects themselves. I've added an example on the wiki that explains why it is less error-prone to use the name of an object instead of the object itself.
At some point, a bug was introduced and remove = TRUE stopped working for character vectors. And since we never checked for the objects themselves when remove = TRUE, the thing was hopelessly broken. In the patch, some sensible error messages are printed when someone uses objects with remove = TRUE, or when someone uses character vectors when remove = FALSE. I've also added some test cases to the test suite to make sure this doesn't happen again.
So in OpenMx 1.0.4, the following will work:
Log in or register to post comments