Hi,
I am trying to run a Cholesky Decomposition with 3 binary variables and I keep getting the error message
“In model 'multiCholACEModel' Optimizer returned a non-zero status code 6. The model does not satisfy the first-order optimality conditions to the required accuracy, and no improved point for the merit function could be found during the final linesearch (Mx status RED)”
I have tried changing the threshold starting values (the ones currently in there is from the saturated model) and reducing mvnRelEps, but the model still will not converge. I am not sure if this is due to errors in the script or other reasons.
Due to results from the univariate models, I went straight for the AE model.
Any guidance or tips on how to proceed would be greatly appreciated, I have included the script, but due to confidentiality agreements I cannot include any data.
Kind regards/ Lisa
#setting up for the analysis nv <- 3 #number of variables ntv <- nv*2 #number of variables for a pair nth <- 1 #number of thresholds thRows <- paste("th",1:nth,sep="") thFree <- matrix(c(T,T,T),nrow=nth,ncol=nv) thValues <- matrix(c(1.56,0.75,1.74),nrow=nth,ncol=nv) thLBound <- matrix(rep(c(0.001,rep(0.001,nth-1)),nv),nrow=nth,ncol=nv) #constricting the values to be positive thLabels=rep(c("pain","cmd","disability"),2) #Organising the data as ordinal Vars <- c('PAIN','CMD', 'DISABILITY') selVars <- paste(Vars,c(rep(1,nv),rep(2,nv)),sep="") mzDataOrd <- subset(selData, bestzyg==1, selVars) dzDataOrd <- subset(selData, bestzyg==2, selVars) mzDataOrd [,1]<- mxFactor(mzDataOrd[,1], levels = c(0:1)) mzDataOrd [,2]<- mxFactor(mzDataOrd[,2], levels = c(0:1)) dzDataOrd [,1]<- mxFactor(dzDataOrd[,1], levels = c(0:1)) dzDataOrd [,2]<- mxFactor(dzDataOrd[,2], levels = c(0:1)) mzDataOrd [,3]<- mxFactor(mzDataOrd[,3], levels = c(0:1)) mzDataOrd [,4]<- mxFactor(mzDataOrd[,4], levels = c(0:1)) dzDataOrd [,3]<- mxFactor(dzDataOrd[,3], levels = c(0:1)) dzDataOrd [,4]<- mxFactor(dzDataOrd[,4], levels = c(0:1)) mzDataOrd [,5]<- mxFactor(mzDataOrd[,5], levels = c(0:1)) mzDataOrd [,6]<- mxFactor(mzDataOrd[,6], levels = c(0:1)) dzDataOrd [,5]<- mxFactor(dzDataOrd[,5], levels = c(0:1)) dzDataOrd [,6]<- mxFactor(dzDataOrd[,6], levels = c(0:1)) summary(mzDataOrd) summary(dzDataOrd) describe(mzDataOrd) describe(dzDataOrd) # Fit Multivariate ACE Model with RawData and Matrices Input # ----------------------------------------------------------------------- cholSVnv <- c(.5,0,0,.5,0,.5) AFac <- c( "a11","a21","a31", "a22","a32", "a33") CFac <- c( "c11","c21","c31", "c22","c32", "c33") EFac <- c( "e11","e21","e31", "e22","e32", "e33") # Matrices a, c, and e to store a, c, and e path coefficients a <- mxMatrix( type="Lower", nrow=nv, ncol=nv, free=TRUE, values=cholSVnv, labels=AFac, name="a" ) c <- mxMatrix( type="Lower", nrow=nv, ncol=nv, free=FALSE, values=0, labels=CFac, name="c" ) e <- mxMatrix( type="Lower", nrow=nv, ncol=nv, free=TRUE, values=cholSVnv, labels=EFac, name="e" ) # Matrices A, C, and E compute variance components A <- mxAlgebra( expression=a %*% t(a), name="A" ) C <- mxAlgebra( expression=c %*% t(c), name="C" ) E <- mxAlgebra( expression=e %*% t(e), name="E" ) # Algebra to compute total variances and standard deviations (diagonal only) V <- mxAlgebra( expression=A+C+E, name="V" ) I <- mxMatrix( type="Iden", nrow=nv, ncol=nv, name="I") iSD <- mxAlgebra( expression=solve(sqrt(I*V)), name="iSD") # Constraint on variance of Ordinal variables Var1 <- mxConstraint( expression=I*V==I, name="Var1") #if ordinal ## Note that the rest of the mxModel statements do not change for bi/multivariate case # Matrix & Algebra for expected means vector expMean<- mxMatrix( type="Zero", nrow=1, ncol=ntv, name="expMean" ) Thre<- mxMatrix( type="Full", nrow=nth, ncol=nv, free=TRUE, values=thValues, lbound=thLBound, name="Thre" ) Inc<- mxMatrix( type="Lower", nrow=nth, ncol=nth, free=FALSE, values=1, name="Inc" ) ThreInc<- mxAlgebra( expression= Inc %*% Thre, name="ThreInc") expThre<- mxAlgebra( expression= cbind(ThreInc,ThreInc), dimnames=list(thRows,selVars), name="expThre" ) # Algebra for expected variance/covariance matrix in MZ expCovMZ<- 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 expCovDZ<- mxAlgebra( expression= rbind ( cbind(A+C+E , 0.5%x%A+C), cbind(0.5%x%A+C , A+C+E)), name="expCovDZ" ) funML <- mxFitFunctionML() dataMZ <- mxData( observed=mzDataOrd, type="raw" ) expMZ <- mxExpectationNormal( covariance="expCovMZ", means="expMean", dimnames=selVars, thresholds="expThre") dataDZ<- mxData( observed=dzDataOrd, type="raw" ) expDZ<- mxExpectationNormal( covariance="expCovDZ", means="expMean", dimnames=selVars, thresholds="expThre") pars <- list(a, c, e, A, C, E, V, I, iSD) modelMZ <- mxModel( expCovMZ, expMean, Thre, Inc, ThreInc, expThre, dataMZ, expMZ, funML, pars, name="MZ" ) modelDZ <- mxModel( expCovDZ, expMean, Thre, Inc, ThreInc, expThre, dataDZ, expDZ, funML, pars, name="DZ") multi <- mxFitFunctionMultigroup( c("MZ","DZ") ) multiCholACEModel <- mxModel( "multiCholACEModel", modelMZ, modelDZ, multi) multiCholACEModel <- mxTryHard(multiCholACEModel) multiCholACEModelfit <- mxRun( multiCholACEModel, intervals=F ) summultiCholACEModel <- summary( multiCholACEModelfit ) summultiCholACEModel