Bivariate Ordinal ACE model with different thresholds
Posted on

Forums
Hi All,
I'd like to run an ACE model - one variable is categorical (2 thresholds) and the other is really continuous, but I thought I'd recode it into deciles (as the joint continuous/categorical implementation in OpenMx 1.1 seems a little way off - and I wouldn't know where to start with the coding).
I think can handle the case of the same number of thresholds across variables, but I was wondering if anyone had a script allowing for a differing number of thresholds for variables, that they'd be willing to share? +/- Independent/Common Pathways.
Of course - it'd be great to hear from anyone who's tried joint categorical/continuous in the beta.
Thanks a lot,
Paul
I'd recommend trying the beta.
An easy way to build one of these that's fairly clear would be to generate your two threshold matrices separately, use rbind to pad the shorter one with zeros, and then cbind the two matrices together.
Something like:
model <- mxModel("myModel", ...
..., # Matrix or algebra thresh1 has nthresh1 thresholds for each of nvars1 variables
..., # Matrix or algebra thresh2 has nthresh2 thresholds for each of nvars2 variables (nthresh2 > nthresh1)
mxAlgebra("Zero", nrow=nthresh2-nthresh1, ncol=nvars1, name="zeropadding1"), # Zeros for padding
mxAlgebra(rbind(thresh1, thresh1padding), name="paddedThresh1"), # Thresh1 padded to thresh2 size
mxAlgebra(cbind(paddedThresh1, thresh2), name="thresholds"), # This is the thresholds matrix for the FIML objective
...,
mxFIMLObjective(...,thresholds="thresholds",...)
)
Note: I'm writing this off the top of my head, there maybe commas or typos.
There's an example in the testing library at http://openmx.psyc.virginia.edu/repoview/1/trunk/models/passing/OrdinalTest.R that is sadly a bit messy--if you build a better version of this that's easier to understand, please share it so others can see.
BUT the beta is also out there. I've run some Joint FIML problems on it myself, but only for testing purposes so far.
Joint Ordinal/Continuous FIML is implemented there and is designed to work the way you would expect--you give it your covariance algebra as usual, you make mxFactors out of the ordinal variables, and you provide a thresholds matrix just like in regular ordinal, but with columns only for the ordinal variables. Use the dimnames to let OpenMx know which threshold goes with which variable. Basically, you treat the ordinal variables like you would in ordinal FIML, and the continuous variables like you would in continuous FIML.
<sales pitch>The benefits of using the beta are many: first, it has joint FIML implemented, which 1.0.x revisions don't. It'll save you the complicated task of coding up a new set of scripts to do joint FIML by hand. If it works as is, then there's no hassle at all. If it doesn't, you get free tech support and we'll work to fix all the bugs you come across. Either way, you can submit your script as a test case when you have one. We'll add it to the library of tests, and ensure that this script and the others like it will keep working in later revisions of OpenMx. Plus, it helps the community and the project.</sales pitch>
Also, the OpenMx 1.1 shouldn't be too far away, so you could just wait for that.
Log in or register to post comments
In reply to I'd recommend trying the beta. by tbrick
Thanks Tim, Maybe I'll try
Maybe I'll try the beta.
I tried to install it using the command given on the news page, but get:
> source(http://openmx.psyc.virginia.edu/getNewOpenMx.R)
Error: unexpected '/' in "source(http:/"
I then tried using the commands that the above link to:
> repos <- c('http://openmx.psyc.virginia.edu/testing/')
> install.packages(pkgs=c('OpenMx'), repos=repos)
Warning: unable to access index for repository http://openmx.psyc.virginia.edu/testing/bin/macosx/leopard/contrib/2.13
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘OpenMx’ is not available (for R version 2.13.0)
On a mac with the latest version of R.
Thanks
Log in or register to post comments
In reply to Thanks Tim, Maybe I'll try by pgseye
We currently support R 2.12 and 2.11
Log in or register to post comments
In reply to We currently support R 2.12 and 2.11 by rgore
Oh we should be able to
Log in or register to post comments
In reply to Thanks Tim, Maybe I'll try by pgseye
Putting quotes (' ') around the source command
Log in or register to post comments
In reply to Thanks Tim, Maybe I'll try by pgseye
We now support 2.13 via the technology of symbolic links
source("http://openmx.psyc.virginia.edu/getNewOpenMx.R")
Tip of the cap to Spiegel for symbolic link directive.
Log in or register to post comments
Thanks Guys, I reverted back
I reverted back to 2.12 and it works fine.
To Tim (and others with the know-how), would you be able to give me some advice/tips on how to do this. At the risk of embarrassing myself, I've attached a script (can also send the data if helpful), but I'm quite clueless as to the coding (normally take existing scripts and adapt them for my own use).
So you'd set the ACE model up as if it had 2 variables right - just as you would normally? Everything up until the means/thresholds statements is also essentially the same?
Stuck after that. If i try to run it I get:
Warning messages:
1: In matrix(values, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]
2: In matrix(labels, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]
3: In matrix(values, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]
4: In matrix(labels, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]
5: In matrix(values, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]
6: In matrix(labels, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]
>
> jointACEFit <- mxRun(jointACEModel, intervals=T)
Running jointACE
Error: The expected means vector associated with the FIML objective in model 'MZ' is not of the same length as the 'dimnames' argument provided by the objective function. The 'dimnames' argument is of length 4 and the expected means vector has 2 columns.
Any help would be greatly appreciated.
Thanks a lot
Log in or register to post comments