Bivariate ACE model with covariates for continuous and ordinal variables
I couldn't find any existing OpenMx codes to conduct bivariate genetic modelling for continuous and ordinal variables with covariates, so I've adapted Hermine Mae's twoACEvj.R code (bivariate ACE model for continuous and ordinal variables) by adding covariates to the code. I've done so by introducing separate regression coefficients for the continuous and ordinal variables. The code ran successfully, and the output seemed to be quite reasonable - the estimated ACE for the continuous variable was similar to the univariate ACE output, but the ordinal variable's estimated ACE was quite different: Bivariate's ACE output = (.61, 0, .39); Univariate ACE output = (.48, .11, .41).
If it helps, I have included a segment of my code with how I incorporated the covariates below. Any advice or comments will be greatly appreciated! Thanks!
# PREPARE MODEL
# Matrix for moderating/interacting variable
defSex <- mxMatrix( type="Full", nrow=1, ncol=2, free=FALSE,
labels=c("data.Sex1","data.Sex2"), name="Sex")
# Matrices declared to store linear Coefficients for covariate
B_SexOrd <- mxMatrix( type="Full", nrow=nth, ncol=1, free=TRUE,
values= .01, labels="betaSexOrd", name="bSexOrd")
B_SexCon <- mxMatrix( type="Full", nrow=1, ncol=2, free=c(T,F),
values= c(.01, 0), labels=c('bSexV1','bSexV2'), name="bSexCon")
meanSexOrd <- mxAlgebra( bSexOrd%x%Sex, name="SexROrd")
meanSexCon <- mxAlgebra( bSexCon%x%Sex, name="SexRCon")
#age
defAge <- mxMatrix( type="Full", nrow=1, ncol=2, free=FALSE,
labels=c("data.Age1","data.Age2"), name="Age")
# Matrices declared to store linear Coefficients for covariate
B_AgeOrd <- mxMatrix( type="Full", nrow=nth, ncol=1, free=FALSE,
values= 0, labels="betaAgeOrd", name="bAgeOrd")
B_AgeCon <- mxMatrix( type="Full", nrow=1, ncol=2, free=c(T,F),
values= c(.01,0), labels=c('bAgeV1','bAgeV2'), name="bAgeCon")
meanAgeOrd <- mxAlgebra( bAgeOrd%x%Age, name="AgeROrd")
meanAgeCon <- mxAlgebra( bAgeCon%x%Age, name="AgeRCon")
#YrsEd
defYEd <- mxMatrix( type="Full", nrow=1, ncol=2, free=FALSE,
labels=c("data.yrsEd1","data.yrsEd2"), name="YEd")
# Matrices declared to store linear Coefficients for covariate
B_YEdOrd <- mxMatrix( type="Full", nrow=nth, ncol=1, free=FALSE,
values= 0, labels="betaYEdOrd", name="bYEdOrd")
B_YEdCon <- mxMatrix( type="Full", nrow=1, ncol=2, free=c(T,F),
values= c(.01, 0), labels=c('bYEdV1','bYEdV2'), name="bYEdCon")
meanYEdOrd <- mxAlgebra( bYEdOrd%x%YEd, name="YEdROrd")
meanYEdCon <- mxAlgebra( bYEdCon%x%YEd, name="YEdRCon")
#Age-related hearing condition
defAHearing <- mxMatrix( type="Full", nrow=1, ncol=2, free=FALSE,
labels=c("data.AHearing1","data.AHearing2"), name="AHearing")
# Matrices declared to store linear Coefficients for covariate
B_AHearingOrd <- mxMatrix( type="Full", nrow=nth, ncol=1, free=TRUE,
values= .01, labels="betaAHearOrd", name="bAHearingOrd")
B_AHearingCon <- mxMatrix( type="Full", nrow=1, ncol=2, free=c(T,F),
values= c(.01, 0), labels=c('bAHearV1','bAHearV2'), name="bAHearingCon")
meanAHearingOrd <- mxAlgebra( bAHearingOrd%x%AHearing, name="AHearingROrd")
meanAHearingCon <- mxAlgebra( bAHearingCon%x%AHearing, name="AHearingRCon")
#Bilateral hearing condition
defBHearing <- mxMatrix( type="Full", nrow=1, ncol=2, free=FALSE,
labels=c("data.BHearing1","data.BHearing2"), name="BHearing")
# Matrices declared to store linear Coefficients for covariate
B_BHearingOrd <- mxMatrix( type="Full", nrow=nth, ncol=1, free=FALSE,
values= 0, labels="betaBHearOrd", name="bBHearingOrd")
B_BHearingCon <- mxMatrix( type="Full", nrow=1, ncol=2, free=c(T,F),
values= c(.01, 0), labels=c('bBHearV1','bBHearV2'), name="bBHearingCon")
meanBHearingOrd <- mxAlgebra( bBHearingOrd%x%BHearing, name="BHearingROrd")
meanBHearingCon <- mxAlgebra( bBHearingCon%x%BHearing, name="BHearingRCon")
# Matrix & Algebra for expected means vector and expected thresholds
intercept <- mxMatrix( type="Full", nrow=1, ncol=ntv, free=c(T,F),
values=c(3,0),
labels=c("meanP","binary"), name="intercept" )
threG <- mxMatrix( type="Full", nrow=nth, ncol=nv, free=TRUE, values=svTh, lbound=lbTh, labels=labThZ, name="Thre" )
inc <- mxMatrix( type="Lower", nrow=nth, ncol=nth, free=FALSE, values=1, name="Inc" )
threT <- mxAlgebra( expression= Inc %*% Thre, name="expThre" )
threC <- mxAlgebra( expression = expThre + AgeROrd + SexROrd + YEdROrd + AHearingROrd + BHearingROrd, name = "expThreC") #with covariates
expMean <- mxAlgebra( intercept + AgeRCon + SexRCon + YEdRCon + AHearingRCon + BHearingRCon, name="expMean")
inclusions <- list (defSex, B_SexOrd, B_SexCon, meanSexOrd, meanSexCon, defAge, B_AgeOrd, B_AgeCon, meanAgeOrd, meanAgeCon,
defYEd, B_YEdOrd, B_YEdCon, meanYEdOrd, meanYEdCon, defAHearing, B_AHearingOrd, B_AHearingCon, meanAHearingOrd, meanAHearingCon,
defBHearing, B_BHearingOrd, B_BHearingCon, meanBHearingOrd, meanBHearingCon, expMean, intercept, threG, threT, threC)
And the specification for expMZ and expDZ:
# Objective objects for Multiple Groups
expMZ <- mxExpectationNormal( covariance="expCovMZ", means="expMean",
dimnames=c('Vars1','PVars1','Vars2','PVars2'),
thresholds="expThreC",
threshnames=c('PVars1','PVars2')
)
expDZ <- mxExpectationNormal( covariance="expCovDZ", means="expMean",
dimnames=c('Vars1','PVars1','Vars2','PVars2'),
thresholds="expThreC",
threshnames=c('PVars1','PVars2')
)
output?
What exactly are these numbers?
Log in or register to post comments
In reply to output? by AdminRobK
ACE estimates of the ordinal variable
These are the ACE estimates of the ordinal variable from the bivariate and univariate analyses respectively.
I've attached the full R script if that helps.
Thank you very much for your help!
Yi Ting
Log in or register to post comments
Kronecker products
Log in or register to post comments
Bivariate analyses of
Log in or register to post comments