You are here

Binary variable in 1.2 beta vs. 1.1.2

5 posts / 0 new
Last post
Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Binary variable in 1.2 beta vs. 1.1.2

I am fitting a model with one binary variable and one latent variable. The goal was to estimate the threshold (and then the proportion) of the binary variable. The following syntax worked in OpenMx 1.1.2 but failed in OpenMx 1.2 beta. Attached are the output.

Any suggestions? Thanks in advance.

Mike

### Fitting a binary variable

library(OpenMx)
## Create n=100 binary data with p=.6
my.df <- data.frame(x=c(rep(0,each=40),rep(1,each=60)))
## Starting value for the threshold
st <- qnorm(colMeans(my.df))
my.df$x <- mxFactor(my.df$x, levels=c(0,1))

prop.Model <- mxModel("Binary variable", mxData(my.df, type="raw"),
mxMatrix(type="Full", nrow=1, ncol=2, values=c(0,1), free=FALSE, name="A"),
mxMatrix(type="Diag", nrow=2, ncol=2, values=c(1,1), free=FALSE, name="S"),
mxMatrix(type="Full", nrow=1, ncol=2, values=c(1,0), free=FALSE, name="F"),
mxMatrix(type="Full", nrow=1, ncol=2, values=c(0,0), free=FALSE, name="M"),
mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=st, labels="th1", name="thresh"),
mxRAMObjective("A", "S", "F", "M", dimnames=c("x","f1"),
thresholds="thresh", threshnames=c("x"))
)
prop.fit <- mxRun(prop.Model)
summary(prop.fit)

### OpenMx version (1.2 beta): "999.0.0-1876"

> prop.fit <- mxRun(prop.Model)
Running Binary variable
Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings, :
BLAS/LAPACK routine 'OMXUNS' gave error code -10

### OpenMx version: "1.1.2-1818"

data:
$Binary variable.data
x
0:40
1:60

free parameters:
name matrix row col Estimate Std.Error lbound ubound
1 th1 thresh 1 x -0.3583366 0.1793284

observed statistics: 100
estimated parameters: 1
degrees of freedom: 99
-2 log likelihood: 134.6023
saturated -2 log likelihood: NA
number of observations: 100
chi-square: NA
p: NA
Information Criteria:
df Penalty Parameters Penalty Sample-Size Adjusted
AIC -63.39767 136.6023 NA
BIC -321.30951 139.2075 136.0493
CFI: NA
TLI: NA
RMSEA: NA
timestamp: 2011-12-28 22:30:14
frontend time: 0.1774709 secs
backend time: 0.002981901 secs
independent submodels time: 0.0001196861 secs
wall clock time: 0.1805725 secs
cpu time: 0.1805725 secs
openmx version number: 1.1.2-1818

Ryne's picture
Offline
Joined: 07/31/2009 - 15:12
I don't know what the problem

I don't know what the problem is thus far, but we're looking into it, Mike.

ryne

tbrick's picture
Offline
Joined: 07/31/2009 - 15:10
Script Error + OpenMx Error

This looks like a combination of a script error and a bug in OpenMx error checking.

The script error (and therefore your quick fix) is that your A matrix is non-conformable to the operation. The A matrix should be of the same order as the S matrix (in this case, 2x2), and you'll want to add two more zeros appropriately. I changed it to:

mxMatrix(type="Full", nrow=2, ncol=2, values=c(0,0,1,0), free=FALSE, name="A"),

and got the same threshold estimates, std. errors, and -2 log likelihood as your listed version 1.1.2 output.

The second problem, of course, is that users should never be getting a BLAS/LAPACK error directly--OpenMx should be noticing the error condition and giving you an error message that makes more sense in your context. We'll make sure to fix this for future releases.

Thanks for your help in hunting bugs! Do you mind if we keep a modified version of this script in our test bank for the future?

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Thanks, Timothy. It works

Thanks, Timothy. It works fine.

Feel free to use the script.

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
Oops. I committed a patch to

Oops. I committed a patch to the OpenMx 1.1 and 1.2 repositories that issues the error message:

Error: The RAM objective in model 'Binary variable' has an A matrix 
with dimensions 1 x 2 and a S matrix with dimensions 2 x 2

Thanks for bringing this to our attention!