Including covariates in your model Sarah Medland
Before I forget… http://www.statmethods.net/
The approach up till now… Account for sex by using different means matrices for males and females Ignore other covariates This is a very bad idea… Be guided by the literature Age, Sex, Age2, SES, birthweight…
Can you include a covariate that is in itself influenced by genes? Eg correcting for total brain size when estimating the heritability of specific brain regions Depends on your research question Is it a moderator or a confounder
Accounting or correcting for a covariate Most common method Add a correction in the form of a linear regression to the mean If the covariate is binary code it as 0 vs 1 expMean = intercept + β*covariate Coded 0/1 Mean for the group coded 0 Unstandarised regression B/ the devition of group 1 from group 0
expMean = intercept + β*covariate Coded 0/1 expMean = intercept + β*covariate Mean for the group coded 0 Unstandarised regression B/ the devition of group 1 from group 0
Setting this up in openMx… intercept <- mxMatrix( type="Full", nrow=1, ncol=ntv, free=TRUE, values= 20, label="mean", name="Mean" ) # 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_Sex <- mxMatrix( type="Full", nrow=1, ncol=1, free=TRUE, values= .01, label="betaSex", name="bSex" ) meanSex <- mxAlgebra( bSex%*%Sex, name="SexR") expMean <- mxAlgebra( Mean + SexR + AgeR, name="expMean") defs <- list( intercept, defSex, B_Sex, meanSex)
Setting this up in openMx… intercept <- mxMatrix( type="Full", nrow=1, ncol=ntv, free=TRUE, values= 20, label="mean", name="Mean" ) 1*2 matrix Containing 2 elements 𝑚𝑒𝑎𝑛 𝑚𝑒𝑎𝑛 Start value =20 20 20
Setting this up in openMx… # Matrix for moderating/interacting variable defSex <- mxMatrix( type="Full", nrow=1, ncol=2, free=FALSE, labels=c("data.sex1","data.sex2"), name="Sex") 1*2 matrix Containing 2 elements – the values of sex1 and sex2 𝑠𝑒𝑥1 𝑠𝑒𝑥2 This matrix is repopulated for each family with the actual values of sex1 and sex2
Setting this up in openMx… B_Sex <- mxMatrix( type="Full", nrow=1, ncol=1, free=TRUE, values= .01, label="betaSex", name="bSex" ) 1*1 matrix Containing 1 element – the unstandardise regression beta for sex on bmi 𝐵 𝑠𝑒𝑥 This element will be estimated and has a start value of .01 .01
Setting this up in openMx… meanSex <- mxAlgebra( bSex%*%Sex, name="SexR") 𝐵 𝑠𝑒𝑥 * 𝑠𝑒𝑥1 𝑠𝑒𝑥2 = 𝐵 𝑠𝑒𝑥 .𝑠𝑒𝑥1 𝐵 𝑠𝑒𝑥 .𝑠𝑒𝑥2 expMean <- mxAlgebra( Mean + SexR + AgeR, name="expMean") 𝑚𝑒𝑎𝑛 𝑚𝑒𝑎𝑛 + 𝐵 𝑠𝑒𝑥 .𝑠𝑒𝑥1 𝐵 𝑠𝑒𝑥 .𝑠𝑒𝑥2 = 𝑚𝑒𝑎𝑛+𝐵 𝑠𝑒𝑥 .𝑠𝑒𝑥1 𝑚𝑒𝑎𝑛+𝐵 𝑠𝑒𝑥 .𝑠𝑒𝑥2 Eg: = 20+(.5∗0) 20+(.5∗1) = 20 20.5
Lets give it a go… twinACE.R twinACECovSex.R Does it make a difference to the fit? 3. twinACECovSexAge.R Lets build a script together?