This is the first time I use open Mx.
without such covariates, my script runs.
Now, I add age and sex as definition factors. results show :
'Unknown thresholds name 'expThreMZ1' detected in the objective function of model 'MZ'.
I don`t know what is wrong. So if you could give me some help? Thanks.
=================================================
MeanL <-mxMatrix( type="Zero", nrow=1, ncol=ntv, name="M" )
Inc <-mxMatrix( type="Lower", nrow=nth, ncol=nth, free=FALSE, values=1, name="L" )
Tmz <-mxMatrix(type="Full", ........, name="ThMZ" )
ThreMZ<-mxAlgebra( expression= L %*% ThMZ, name="expThreMZ" )
Tdz <-mxMatrix(type="Full", ........., name="ThDZ" )
ThreDZ<-mxAlgebra( expression= L %*% ThDZ, name="expThreDZ" )
CorMZ <-mxMatrix(type="Stand", nrow=ntv, ncol=ntv, free=T, values=.6, lbound=-.99, ubound=.99, name="expCorMZ")
CorDZ <-mxMatrix(type="Stand", nrow=ntv, ncol=ntv, free=T, values=.3, lbound=-.99, ubound=.99, name="expCorDZ")
Data objects for Multiple Groups
dataMZ <- mxData( observed=mzDataF, type="raw" )
dataDZ <- mxData( observed=dzDataF, type="raw" )
defination var
ageT1MZ <- as.vector(subset(ukdata, zg==1, age1))
ageT2MZ <- as.vector(subset(ukdata, zg==1, age2))
ageT1DZ <- as.vector(subset(ukdata, zg==2, age1))
ageT2DZ <- as.vector(subset(ukdata, zg==2, age2))
sexT1MZ <- as.vector(subset(ukdata, zg==1, sex1))
sexT2MZ <- as.vector(subset(ukdata, zg==1, sex2))
sexT1DZ <- as.vector(subset(ukdata, zg==2, sex1))
sexT2DZ <- as.vector(subset(ukdata, zg==2, sex2))
Co <- mxMatrix( type="Full", nrow=2, ncol=2, free=TRUE, values= 0.1, label=c("betaAge","betaSex"), name="beta")
Algebra for making the means a function of the definition variables age and sex
DefMZ <- mxMatrix( type="Full", nrow=2, ncol=2, free=F, label=c("data.ageT1MZ","data.sexT1MZ","data.ageT2MZ","data.sexT2MZ"), name="MZDefVars")
DefMZ1 <- mxAlgebra( expression=expThreMZ + beta %*% MZDefVars, name="expThreMZ1")
DefDZ <- mxMatrix( type="Full", nrow=2, ncol=2, free=F, label=c("data.ageT1DZ","data.sexT1DZ","data.ageT2DZ","data.sexT2DZ"), name="DZDefVars")
DefDZ1 <- mxAlgebra( expression=expThreDZ+ beta %*% DZDefVars, name="expThreDZ1")
objMZ <- mxFIMLObjective( covariance="expCorMZ", means="M", dimnames=selVars, thresholds="expThreMZ1" )
objDZ <- mxFIMLObjective( covariance="expCorDZ", means="M", dimnames=selVars, thresholds="expThreDZ1" )
Combine Groups
modelMZ <- mxModel( MeanL, Inc, Tmz, ThreMZ, CorMZ, dataMZ,objMZ, name="MZ" )
modelDZ <- mxModel( MeanL, Inc, Tdz, ThreDZ, CorDZ, dataDZ,objDZ, name="DZ" )
minus2ll <- mxAlgebra( expression=MZ.objective + DZ.objective, name="m2LL" )
obj <- mxAlgebraObjective( "m2LL" )
Conf <- mxCI (c ('MZ.expCorMZ[2,1]', 'DZ.expCorDZ[2,1]') )
SatModel <- mxModel( "Sat", modelMZ, modelDZ, minus2ll, obj, Conf )
-------------------------------------------------------------------------------------------------------------------------------
1) RUN Saturated Model
SatFit <- mxRun(SatModel, intervals=T)