You are here

the continuous part of the model is not positive definite

2 posts / 0 new
Last post
lior abramson's picture
Offline
Joined: 07/21/2017 - 13:13
the continuous part of the model is not positive definite

Hello,
I would like to ask your help with an error message that I cannot figure out.

First, some general details about my openMx version:

OpenMx version: 2.7.17 [GIT v2.7.17]
R version: R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32
Default optimiser: CSOLNP
NPSOL-enabled?: No
OpenMP-enabled?: No

I am trying to do a bivariate Cholesky model with paths specifications, with a syntax that worked before...
For some reason I get the following error message:

Running ACE_Cholesky with 11 parameters
Error: The job for model 'ACE_Cholesky' exited abnormally with the error message: fit is not finite (The continuous part of the model implied covariance (loc2) is not positive definite in data 'DZ.data' row 510. Detail:
covariance = matrix(c( # 4x4
0.457441, 0.22872, 0.686161, 0
, 0.22872, 0.457441, 0.686161, 0
, 0.686161, 0.686161, 1.95546, 0
, 0, 0, 0, 0), byrow=TRUE, nrow=4, ncol=4)
)
In addition: Warning message:
In model 'ACE_Cholesky' Optimizer returned a non-zero status code 10. Starting values are not feasible. Consider mxTryHard()

I tried to change the starting values and also to change the command to mxTryHard. I have no idea what to do with the first error message (there is nothing different in row 510 in the dataset).

I attach the syntax itself. I would really appreciate your help in solving the problem.
Thank you very much

require("OpenMx")
 
#start values
meanEMP1 <-mean(na.omit(D$empathy3Mom_1))
meanEMP2 <-mean(na.omit(D$empathy3Mom_2))
StartMeanEMP <-mean(c(meanEMP1,meanEMP2))
 
meanSOC1 <-mean(na.omit(D$sociableMom3_1))
meanSOC2 <-mean(na.omit(D$sociableMom3_2))
StartMeanSOC <-mean(c(meanSOC1,meanSOC2))
 
EMP <-c(D$empathy3Mom_1,D$empathy3Mom_2) 
StartVarEMP.ACE <-sqrt(var(na.omit(EMP))/3) 
 
SOC <-c(D$sociableMom3_1, D$sociableMom3_2) 
StartVarSOC.ACE <-sqrt(var(na.omit(SOC))/3)
 
# Select Variables for Analysis
selVars <- c('sociableMom3_1','sociableMom3_2','empathy3Mom_1','empathy3Mom_2')
aceVars <- c("A1_SOC","C1_SOC","E1_SOC","A2_SOC","C2_SOC","E2_SOC",
             "A1_EMP","C1_EMP","E1_EMP","A2_EMP","C2_EMP","E2_EMP")
 
# Select Data for Analysis
mz <- subset(D, zygosity==1,selVars)
dz <- subset(D, zygosity==2,selVars)
 
 
# Path objects for Multiple Groups
manifestVars=selVars
latentVars=aceVars
 
# specify paths for the variances and means of the latent variables
latVariances <- mxPath( from=aceVars, arrows=2,
                        free=FALSE, values=1 )
 
 
# means of latent variables
latMeans <- mxPath( from="one", to=aceVars, arrows=1,
                    free=FALSE, values=0 )
 
#specify paths for the means of the observed variables.
obsMeans <- mxPath( from="one", to=selVars, arrows=1,
                    free=c(T,T,T,T), 
                    values=c(StartMeanEMP, StartMeanEMP,StartMeanSOC, StartMeanSOC), 
                    labels=c("mean_EMP" ,"mean_EMP","mean_SOC","mean_SOC"
                    ) )
 
 
# path coefficients for twin 1. 
pathAceT1_SOC <- mxPath( from=c("A1_SOC","C1_SOC","E1_SOC"), 
                         to="sociableMom3_1", arrows=1, free=c(T,T,T), 
                         values=c(StartVarSOC.ACE,StartVarSOC.ACE,StartVarSOC.ACE),
                         label=c("aSOC","cSOC" ,"eSOC"))
 
 
 
pathAceT1_EMP <- mxPath( from=c("A1_SOC","C1_SOC","E1_SOC","A1_EMP","C1_EMP","E1_EMP"), 
                         to="empathy3Mom_1", arrows=1, free=c(T,T,T,T,T,T), 
                         values= c(StartVarSOC.ACE,StartVarSOC.ACE,StartVarSOC.ACE,
                                   StartVarEMP.ACE,StartVarEMP.ACE,StartVarEMP.ACE),
                         label=c("aSOC_EMP","cSOC_EMP" ,"eSOC_EMP","aEMP","cEMP" ,"eEMP") )
 
 
# path coefficients for twin 2
pathAceT2_SOC <- mxPath( from=c("A2_SOC","C2_SOC","E2_SOC"), 
                         to="sociableMom3_2", arrows=1, free=c(T,T,T), 
                         values=c(StartVarSOC.ACE,StartVarSOC.ACE,StartVarSOC.ACE),
                         label=c("aSOC","cSOC" ,"eSOC"))
 
 
 
pathAceT2_EMP <- mxPath( from=c("A2_SOC","C2_SOC","E2_SOC","A2_EMP","C2_EMP","E2_EMP"), 
                         to="empathy3Mom_1", arrows=1, free=c(T,T,T,T,T,T), 
                         values= c(StartVarSOC.ACE,StartVarSOC.ACE,StartVarSOC.ACE,StartVarEMP.ACE,StartVarEMP.ACE,StartVarEMP.ACE),
                         label=c("aSOC_EMP","cSOC_EMP" ,"eSOC_EMP","aEMP","cEMP" ,"eEMP"))
 
 
# covariance between C1 & C2
covC1C2_SOC <- mxPath( from="C1_SOC", to="C2_SOC", arrows=2,free=FALSE, values=1 )
covC1C2_EMP <- mxPath( from="C1_EMP", to="C2_EMP", arrows=2,free=FALSE, values=1 )
 
 
# covariance between A1 & A2 in MZ's
covA1A2_MZ_SOC <-mxPath( from="A1_SOC", to="A2_SOC", arrows=2, free=FALSE,values=1 )
covA1A2_MZ_EMP <-mxPath( from="A1_EMP", to="A2_EMP", arrows=2, free=FALSE,values=1 )
# covariance between A1 & A2 in DZ's
covA1A2_DZ_SOC <-mxPath( from="A1_SOC", to="A2_SOC",arrows=2, free=FALSE,values=.5 )
covA1A2_DZ_EMP <-mxPath( from="A1_EMP", to="A2_EMP",arrows=2, free=FALSE,values=.5 )
 
#call the data.frame with the MZ raw data, mzData, and the DZ raw data
dataMZ <- mxData( observed=mz, type="raw" )
dataDZ <- mxData( observed=dz, type="raw" )
 
# Combine Groups
#arange together all the paths that are the same for MZ and DZ
paths <- list(latVariances, latMeans, obsMeans,pathAceT1_SOC,
              pathAceT2_SOC,pathAceT1_EMP,pathAceT2_EMP,covC1C2_SOC,covC1C2_EMP)
 
 
#Build a model seperately for MZ and DZ and for each sex
modelMZ <- mxModel(model="MZ", type="RAM", manifestVars=selVars,
                   latentVars=aceVars, paths, covA1A2_MZ_SOC
                   ,covA1A2_MZ_EMP, dataMZ)
modelDZ <- mxModel(model="DZ", type="RAM", manifestVars=selVars,
                   latentVars=aceVars, paths,covA1A2_DZ_SOC
                   ,covA1A2_DZ_EMP, dataDZ )
 
 
#Ask for confidence intervals
CI <-mxCI(reference = c('aSOC','cSOC','eSOC','aSOC_EMP','cSOC_EMP','eSOC_EMP','aEMP','cEMP','eEMP'), 
          interval = 0.95, type=c("both", "lower", "upper"))
 
obj <- mxFitFunctionMultigroup(c("MZ","DZ"))
modelACE.Cholesky <- mxModel(model="ACE_Cholesky", modelMZ, modelDZ, obj, CI )
 
#mxOption(NULL, "Default optimizer", "NPSOL")
 
fitACE.Cholesky <- mxRun(modelACE.Cholesky, intervals=TRUE) 
AdminRobK's picture
Offline
Joined: 01/24/2014 - 12:15
copy-paste mistake
Error: The job for model 'ACE_Cholesky' exited abnormally with the error message: fit is not finite (The continuous part of the model implied covariance (loc2) is not positive definite in data 'DZ.data' row 510. Detail:
covariance = matrix(c( # 4x4
0.457441, 0.22872, 0.686161, 0
, 0.22872, 0.457441, 0.686161, 0
, 0.686161, 0.686161, 1.95546, 0
, 0, 0, 0, 0), byrow=TRUE, nrow=4, ncol=4)
)

This matrix is non-PD because its fourth diagonal element is zero (and in fact, its fourth column and row are all zeroes). In other words, "empathy3Mom_2" has a model-expected variance of zero. The problem is here:

pathAceT2_EMP <- mxPath( from=c("A2_SOC","C2_SOC","E2_SOC","A2_EMP","C2_EMP","E2_EMP"), 
                         to="empathy3Mom_1", arrows=1, free=c(T,T,T,T,T,T), 
                         values= c(StartVarSOC.ACE,StartVarSOC.ACE,StartVarSOC.ACE,StartVarEMP.ACE,StartVarEMP.ACE,StartVarEMP.ACE),
                         label=c("aSOC_EMP","cSOC_EMP" ,"eSOC_EMP","aEMP","cEMP" ,"eEMP"))

You need to change to="empathy3Mom_1" to to="empathy3Mom_2".

Log in or register to post comments