# Strange Error Message

14 posts / 0 new
Offline
Joined: 03/08/2010 - 17:14
Strange Error Message

Hi All:

I just got this strange error message when I ran the script below (trying to use a covariance matrix rather than raw data).

Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings, :
BLAS/LAPACK routine 'DSYMM ' gave error code -9

Here is the script that generated the error:

require(OpenMx)
source("http://www.vipbg.vcu.edu/~vipbg/Tc24/GenEpiHelperFunctions.R")

mzCov <- matrix(c(1, .6, .6, 1), 2,
dimnames=list(c("y1", "y2"), c("y1", "y2")))
dzCov <- matrix(c(1, .4, .4, 1), 2,
dimnames=list(c("y1", "y2"), c("y1", "y2")))

# Fit Multivariate ACE Model using Cholesky Decomposition
# -----------------------------------------------------------------------

Vars <- c("y1", "y2")

nv <- 2
selVars <- paste(Vars,c(rep(1,nv),rep(2,nv)),sep="")

ntv <- nv*2
mzData <- mzCov
dzData <- dzCov

# Fit Multivariate ACE Model using Cholesky Decomposition
# -----------------------------------------------------------------------

multACEModel <- mxModel("multACE",
mxModel("ACE",
# Matrices a, c, and e to store a, c, and e path coefficients
mxMatrix( type="Lower", nrow=nv, ncol=nv, free=TRUE, values=.6,label=c("a11", "a21","a22"), name="a" ),
mxMatrix( type="Lower", nrow=nv, ncol=nv, free=TRUE, values=.6,label=c("c11", "c21","c22"), name="c" ),
mxMatrix( type="Lower", nrow=nv, ncol=nv, free=TRUE, values=.6,label=c("e11", "e21","e22"), name="e" ),

# Matrices A, C, and E compute variance components
mxAlgebra( expression=a %*% t(a), name="A" ),
mxAlgebra( expression=c %*% t(c), name="C" ),
mxAlgebra( expression=e %*% t(e), name="E" ),

# Algebra to compute total variances and standard deviations (diagonal only)
mxAlgebra( expression=A+C+E, name="V" ),
mxMatrix( type="Iden", nrow=nv, ncol=nv, name="I"),
mxAlgebra( expression=solve(sqrt(I*V)), name="isd"),

# Matrix & Algebra for expected means vector
# mxMatrix( type="Full", nrow=1, ncol=nv, free=TRUE, values= .5, name="M" ),
# mxAlgebra( expression= cbind(M,M), name="expMean"),

# Algebra for expected variance/covariance matrix in MZ
mxAlgebra( expression= rbind ( cbind(A+C+E , A+C),
cbind(A+C , A+C+E)), name="expCovMZ" ),

# Algebra for expected variance/covariance matrix in DZ, note use of 0.5, converted to 1*1 matrix
mxAlgebra( expression= rbind ( cbind(A+C+E , 0.5%x%A+C),
cbind(0.5%x%A+C , A+C+E)), name="expCovDZ" )
),

mxModel("MZ",
mxData(observed=dzCov , type="cov", numObs=100 ),
mxMLObjective( covariance="ACE.expCovMZ", dimnames=selVars )
),

mxModel("DZ",
mxData( observed=dzCov , type="cov", numObs=100 ),
mxMLObjective( covariance="ACE.expCovDZ", dimnames=selVars )
),
mxAlgebra( expression=MZ.objective + DZ.objective, name="2sumll" ),
mxAlgebraObjective("2sumll")
)

multACEFit <- mxRun(multACEModel, intervals=F)
multACESumm <- summary(multACEFit)
multACESumm

Offline
Joined: 07/31/2009 - 15:10
Congratulations! You just

Congratulations!

You just found a bug in OpenMx. I'm in the process of investigating, and we'll get back to you with a fix as soon as we can.

Thanks for finding this.

Offline
Joined: 07/31/2009 - 15:24
I believe that ACE.expCovMZ

I believe that ACE.expCovMZ and ACE.expCovDZ are 4 x 4 matrices but the observed covariance matrices are both 2 x 2 matrices. Can someone confirm this? I'll add error checking to ML to ensure that the dimensions match up.

Offline
Joined: 07/31/2009 - 15:10
That lines up with everything

That lines up with everything I'm seeing. Checking the math, it looks right as well.

When I change the observed covariances to 4x4 matrices, it runs fine.

If this is intended to be a bivariate model of twin pairs, that also lines up--two measurements per person times two twins per pair should yield four measurements in every row. That means the covariance matrix should be 4x4.

bverhulst, your quick fix is just to add rows and columns to your observed covariance matrix to make it 4x4. We'll add the error checking so that the error you'll get back in the future will make more sense.

Thanks again for your help!

Offline
Joined: 03/08/2010 - 17:14
That seems to work. I ended

That seems to work. I ended up just scrapping everything and starting over and the second time it worked without a problem, but I thought I would post the very strange error message anyway.
Thanks again,
Brad

Offline
Joined: 07/31/2009 - 15:24
The error message in OpenMx

The error message in OpenMx 1.0.5 for this script will be:
Error: The dimensions for the expected covariance matrix and the observed covariance matrix in the ML objective in model 'MZ' are not identical.

Offline
Joined: 09/07/2010 - 17:14
I actually have a related

I actually have a related question to this. Is it permissible to supply a data Cov matrix bigger than the expected one and then the program select relevant the block by the dim names given in the ML objective function? If my memory serves, the FIML can select some columns from the data matrix, leaving others out (e.g. instrumental variables).

Thanks.

Hao

Offline
Joined: 07/31/2009 - 15:12
Yes, that will work. The

Yes, that will work. The dimnames argument selects rows and columns from the data covariance matrix. The order of variables in the dimnames argument will be used to select variables; if you supply a dimnames argument of c("y1", "y5", "y3") that corresponds to a dataset with variables y1-y5 in that order, then the 1st, 5th and 3rd rows & columns of the data will be compared to the 1st, 2nd and 3rd rows & columns of the expected covariance matrix.

Offline
Joined: 09/07/2010 - 17:14
Ryne, Thank you very much for

Ryne,

Thank you very much for the quick reply. But I found it does not work. Would you have a look at the code below?

Below is an example, where varnames include 8 variable names, and varnames0 four of those eight. Upon running the mxRun line, it says

Error: The dimnames for the expected covariance matrix and the observed covariance matrix in the ML objective in model 'ACEModelMZ' are not identical.

require(OpenMx)
varnames<-c(paste("var1_",1:4,sep=""),paste("var2_",1:4,sep=""));
varnames0<-c(paste("var1_",1:2,sep=""),paste("var2_",1:2,sep=""));
dataMZ<-dataDZ<-matrix(diag(1,8),nrow=8,ncol=8,dimnames=list(varnames,varnames));

p<-2;
pstar<-p*(p+1)/2;
nMZ=100;
nDZ=100;
LA<-mxMatrix(type="Lower",nrow=p,ncol=p,free=T,values=0, label=paste("a",1:pstar,sep=""),name="LA");
LC<-mxMatrix(type="Lower",nrow=p,ncol=p,free=T,values=0, label=paste("c",1:pstar,sep=""),name="LC");
LE<-mxMatrix(type="Lower",nrow=p,ncol=p,free=T,values=c(1,.5,sqrt(3)/2), label=paste("e",1:pstar,sep=""),name="LE");

A<-mxAlgebra(expression=LA%*%t(LA),name="A");
C<-mxAlgebra(expression=LC%*%t(LC),name="C");
E<-mxAlgebra(expression=LE%*%t(LE),name="E");

ACESigmaMZ<-mxAlgebra(expression=rbind(cbind(A+C+E,A+C),cbind(A+C,A+C+E)),name="ACESigmaMZ");
ACESigmaDZ<-mxAlgebra(expression=rbind(cbind(A+C+E,.5%x%A+C),cbind(.5%x%A+C,A+C+E)), name="ACESigmaDZ");

ACEModelMZ<-mxModel("ACEModelMZ",
mxMLObjective(covariance="ACEModelTwin.ACESigmaMZ",dimnames=varnames0),
mxData(observed=dataMZ,type="cov",numObs=nMZ));
ACEModelDZ<-mxModel("ACEModelDZ",
mxMLObjective(covariance="ACEModelTwin.ACESigmaDZ",dimnames=varnames0),
mxData(observed=dataDZ,type="cov",numObs=nDZ));
twin<-mxAlgebra(expression=ACEModelMZ.objective+ACEModelDZ.objective,name="twin");
ACEModelTwin<-mxModel("ACEModelTwin",LA,LC,LE,A,C,E,
ACESigmaMZ,ACESigmaDZ,ACEModelMZ,ACEModelDZ,twin,
mxAlgebraObjective("twin"));

mxRun(ACEModelTwin)

Offline
Joined: 07/31/2009 - 15:24
No, for ML estimation the

No, for ML estimation the expected covariance and observed covariance matrices must have identical dimensions and of identical dimnames.

Offline
Joined: 07/31/2009 - 15:12
Oops, thanks Mike. I didn't

Oops, thanks Mike. I didn't realize we had that inconsistency between ML and FIML.

Hao, your code runs on my machine, but yields a code 6, which I assume is because you used the identity matrix as a data example. I did not get a conformability error, despite Mike's comment.

Offline
Joined: 07/31/2009 - 15:24
The error checking was added

The error checking was added in OpenMx 1.0.6

Offline
Joined: 07/31/2009 - 15:12
I'm probably in the 1.0.5

I'm probably in the 1.0.5 range then. Thanks again.

Offline
Joined: 09/07/2010 - 17:14
Thank you, Mike and Ryne, for

Thank you, Mike and Ryne, for the replies.

Log in or register to post comments