(1) am inexperienced in R, so please ignore if this is stupid
(2) the scope of some OpenMx objects allows an object to be replaced by an identically-named object in a user's R session, function, whatever. run the following and note the error "Type must be one of ... "
thisOMxModel <- mxModel(name="testModel")
thisOMxModel <- mxModel(thisOMxModel, mxMatrix(name="Afac", type="Full",nrow=8,ncol=5))
matrixTypes <- c("Full", "Symm: Symmetric", "Diag: Diagonal",
"Stand: Correlation", "Lower: Diagonal and below", "Sdiag: Sub-diagonal",
"Iden: Identity", "Unit: all 1s", "Zero: all 0s")
thisOMxModel <- mxModel(thisOMxModel, mxMatrix(name="RAfac",
(3) the issue comes about from function matrixCheckErrors. this references object matrixTypes. apparently, because the user already has instantiated an object called matrixTypes and then calls mxModel, the user's object--not the OpenMX object-- is evaluated in the statement
if (is.na(match(type, matrixTypes)))
(4) i offer four solutions:
Solution 1: document all such OpenMX objects and instruct users not to have any identically-named objects instantiated before calling OpenMx.
Solution 2: (lottsa work here) cut-and-paste all referenced OpenMx objects directly into functions that use them. e.g., if the statement
matrixTypes <- c("Full", "Symm", "Diag", "Stand", "Lower", "Sdiag", "Iden",
were placed in matrixCheckErrors before the above "if" statement, then the local and not the user's matrixTypes will be used.
Solution 3: (also lottsa work, but perhaps better). create a class with slots (or a list in classes that OpenMx already has) for all such-referenced objects. then evaluate against them. e,g.,
if (is.na(match(type, OpenMx@matrixTypes)))
Solution 4: (probably the best) use your knowledge of R to come with a better solution.