You are here

possible documentation improvement

2 posts / 0 new
Last post
carey's picture
Joined: 10/19/2009 - 15:38
possible documentation improvement

(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 (, 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",
"Unit", "Zero")
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 (, OpenMx@matrixTypes)))
Solution 4: (probably the best) use your knowledge of R to come with a better solution.


mspiegel's picture
Joined: 07/31/2009 - 15:24
We have not turned on

We have not turned on namespaces in the OpenMx package. When we turn on the namespace and export only the names that begin with "mx" and "omx", then matrixTypes will not be visible to the user. Sorry about that.