Hello,
I am new to using umx, so I apologize for asking what is perhaps a very simple question. I am trying to run a bivariate ACE model using binary variables (they are structured as ordered factors). When I run the model, I receive the warning message copied below alongside model output:
In matrix(labels, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]
I saw a few threads describing this error, but they were all in the context of OpenMx code for which nrow and ncol were explicitly specified in the model. Might you be able to advise what the source of this error is and how to remedy, if necessary? Is the output of the bivariate model unreliable given the accompanying warning message?
Here is the code I am using (adapted from Boulder script):
selDVs = c("var1", "var2")
m1 = umxACE(selDVs = selDVs, dzData = dzData,
mzData = mzData, sep = "_T", tryHard = c("ordinal"))
Thank you very much for your time!
Can you post what
traceback()
says immediately after?Does the univariate model run for both var1 and var2?
Also, what does
umxVersion()
say?umxACE is pretty bullet proof and user-input check complete functions so...
Thank you so much for your quick reply! Please find the requested information copied below:
"Can you post what traceback() says immediately after?"
Error: The argument to the '$' or '[' operator applied on a MxModel object must be a single character string
"Does the univariate model run for both var1 and var2?"
Yes, they both run normally and without errors.
"Also, what does umxVersion() say?"
umx version: 4.9.0
OpenMx version: 2.19.8 [GIT v2.19.8]
R version: R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32
Default optimizer: SLSQP
NPSOL-enabled?: No
OpenMP-enabled?: No
Thank you again! Please let me know if there is any other information I can provide.
I can't replicate this. Can you please run the following: It works perfectly for me, at a glance.
with output:
Table: Standardized parameter estimates from a 2-factor Cholesky ACE model. A: additive genetic; C: common environment; E: unique environment.
Table: Means
Thank you again for your help with this! I ran the script you provided in the R twinData and it worked perfectly on my end, too. Unfortunately, I had less success when I applied the code to my data. I wasn't able to create ordinal factors using the umx code here...I kept getting a "node stack overflow" error after I ran this part:
For what it's worth, the variables are already categorical (0,1) but, from what I have gathered, they still need to be structured so that umx recognizes them as such? I ended up having success at this step with mxFactor, and ran the umxACE models in question on ordinal factors created that way. For example:
Might that be relevant here? I may be grasping at straws...
So the error is not the initial one, nor related to umxFactor, or even umxACE, but rather from specifically a run with your data which prints "node stack overflow" while running your model.
Sounds like an OpenMx error. If you can replicate this, I would immediately run traceback() and then create an issue either at or if you think it is from umx. Include the relevant chunk of console output from umxACE() to the end of traceback() so we can see what this error is and work from there.
Possibly will be helpful to either post the data or use mxGenerateData() to make an anonymised simulation. Honestly the error is not making much sense to me, as a bivariate binary umxACE model is bread-and-butter so we'd see it failing all over the place. I suspect something odd about the data or perhaps your install of R/OpenMx.
Might also be worth updating OpenMx as I see they have a new version on CRAN which fixed some memory leaks, which might be relevant to you.. Newest version:
umx_open_CRAN_page("OpenMx")
[1] ‘2.20.0’
Copied below is the traceback() output- I hope that this corresponds to the output requested!
Here is the output with traceback() from the node stack overflow error when trying use umx to create ordinal factors:
Here is the output with traceback() from using mxFactor to create ordinal factors for analysis:
And here is the output with traceback() from umxACE using factors created with mxFactor (in the step above)
Finally, here is the output from mxGenerateData from the bivariate model.
I also went ahead and updated OpenMx as recommended. Please let me know if there is any other information or output I can provide. Thank you for taking time to assist!
Glad mxFactor got you working. So your columns might not be what umxFactor is expecting - I like to have error checking that makes this always work or else clearly say why to the user.
Would you mind please post what this code returns so I can see what you are feeding in (before you pass it into mxFactor?
Here is what I get when I run the code you kindly provided with each of the variables.
Thank you again for taking time to assist!
Apologies for the multiple posts! I realized that my last post was a bit convoluted- I was able to structure my variables correctly using mxFactor, but still got the data length error when running the bivariate models on those variables within umxACE. I hope that makes sense! Thank you!
ah.. that makes sense as umxFactor is working just fine: