# Bivariate Ordinal ACE model with different thresholds

8 posts / 0 new
Offline
Joined: 10/13/2009 - 23:50
Bivariate Ordinal ACE model with different thresholds

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

Offline
Joined: 07/31/2009 - 15:10
I'd recommend trying the beta.

It is certainly possible to define different numbers of thresholds for each variable. You build a thresholds matrix with one column for each variable, and one row for each threshold for whichever variable has the most thresholds. So if there are two variables, one with one threshold and one with nine, the resulting threshold matrix is 9x2. Because the first variable is an MxFactor with two levels, OpenMx will ignore any values in that column after the first one, so you can just fill it with zeros.

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(cbind(paddedThresh1, thresh2), name="thresholds"),      # This is the thresholds matrix for the FIML objective
...,
mxFIMLObjective(...,thresholds="thresholds",...)
)
<code>
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.

&lt;sales pitch&gt;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.&lt;/sales pitch&gt;

Also, the OpenMx 1.1 shouldn't be too far away, so you could just wait for that.
Offline
Joined: 10/13/2009 - 23:50
Thanks Tim, Maybe I'll try

Thanks Tim,

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)

Thanks

Offline
Joined: 01/27/2011 - 16:48
We currently support R 2.12 and 2.11

We currently support R 2.12 and 2.11. Reverting to either of those versions should fix your problem with the linked commands.

Offline
Joined: 07/31/2009 - 15:24
Oh we should be able to

Oh we should be able to provide users with a 2.13 install by giving them the 2.12 install. Place a symbolic link from the 2.13 directory pointing to the 2.12 directory.

Offline
Joined: 01/27/2011 - 16:48
Putting quotes (' ') around the source command

Putting quotes (' ') around the source command: will also work once you are using 2.11 or 2.12. i.e. source('http://openmx.psyc.virginia.edu/getNewOpenMx.R')

Offline
Joined: 01/27/2011 - 16:48
We now support 2.13 via the technology of symbolic links

This should now work with R 2.13 (the version you are using) just make sure you use the following source command:
source("http://openmx.psyc.virginia.edu/getNewOpenMx.R")

Tip of the cap to Spiegel for symbolic link directive.

Offline
Joined: 10/13/2009 - 23:50
Thanks Guys, I reverted back

Thanks Guys,

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