Hi
I am teaching tomorrow and I have a werid glich in my code that I can't resolve
I am modeling the correlations between 3 variables in a very straight forward script. I then want to drop one of the correlations. the difference in fits between the full model and the reduced model is huge and the correlation is not being set to zero
Where have I gone wrong - I can't spot it typo(?)
thanks
Sarah
data(twinData)
selVars <- c('wt1','ht1','bmi1')
nv <- 3
factorData <- subset(twinData, zyg<=5, selVars)
SatModel <- mxModel("saturated",
mxModel("Cor",
mxMatrix( type="Lower", nrow=nv, ncol=nv, free=TRUE, values=.5, name="Chol" ),
mxAlgebra( Chol %*% t(Chol), name="expCov" ),
mxMatrix( type="Full", nrow=1, ncol=nv, free=TRUE, values=c(60,1.5,20), name="expMean" ),
mxData( observed=factorData, type="raw" ),
mxFIMLObjective( covariance="expCov", means="expMean", dimnames=selVars)),
mxAlgebra( Cor.objective , name="modelfit" ),
mxAlgebraObjective("modelfit")
)
SatFit <- mxRun(SatModel)
SatSumm <- summary(SatFit)
SatSumm
Drop1Model <- mxModel("drop1",
mxModel("Cor",
mxMatrix( type="Lower", nrow=nv, ncol=nv, free=c( TRUE,TRUE,TRUE,TRUE,FALSE,TRUE), name="Chol" ),
mxAlgebra( Chol %*% t(Chol), name="expCov" ),
mxMatrix( type="Full", nrow=1, ncol=nv, free=TRUE, values=c(60,1.5,20), name="expMean" ),
mxData( observed=factorData, type="raw" ),
mxFIMLObjective( covariance="expCov", means="expMean", dimnames=selVars)),
mxAlgebra( Cor.objective , name="modelfit" ),
mxAlgebraObjective("modelfit")
)
Drop1Fit <- mxRun(Drop1Model)
Drop1Summ <- summary(Drop1Fit)
Drop1Summ
Drop1Fit$Cor$Chol
Drop1Fit$Cor$expCov