# Adding multiple covariates to ACE model (practical day 3)

**URL:** https://isgw-forum.colorado.edu/t/adding-multiple-covariates-to-ace-model-practical-day-3/777
**Category:** Twin & family modeling
**Tags:** openmx
**Created:** [June 3, 2026, 2:29pm UTC](https://isgw-forum.colorado.edu/t/adding-multiple-covariates-to-ace-model-practical-day-3/777 "2026-06-03T14:29:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tara.henechowicz](https://isgw-forum.colorado.edu/user_avatar/isgw-forum.colorado.edu/tara.henechowicz/32/73_2.png) [@tara.henechowicz](https://isgw-forum.colorado.edu/u/tara.henechowicz)
#### Post date: [June 3, 2026, 2:29pm UTC](https://isgw-forum.colorado.edu/t/adding-multiple-covariates-to-ace-model-practical-day-3/777/1 "2026-06-03T14:29:47Z")

</div>

Hi,  
I wanted to know how I can set up more than one covariate in the script we used for practical day 3 oneSACEvcrH.R  
Would I just add lines to the chunk for the covariates? Is there anything downstream in the script that is affected?  
############ Create Data Objects for Multiple Groups including Observed Phenotypes and Covariates

dataMZ ← mxData( observed=subset(tDat, zyg==1, c(selVars,covVars)), type=“raw” )

dataDZ ← mxData( observed=subset(tDat, zyg==2, c(selVars,covVars)), type=“raw” )

############ Create Matrices for Covariates and linear Regression Coefficients

defSex ← mxMatrix( type=“Full”, nrow=1, ncol=2, free=FALSE, labels=c(“data.sex1”,“data.sex2”), name=“defSex” )

defAge ← mxMatrix( type=“Full”, nrow=1, ncol=1, free=FALSE, labels=c(“data.age”), name=“defAge” )

betaS ← mxMatrix( type=“Full”, nrow=1, ncol=1, free=TRUE, labels=“bS”, name=“betaS” )

betaA ← mxMatrix( type=“Full”, nrow=1, ncol=1, free=TRUE, labels=“bA”, name=“betaA” )

############ Create Algebra for expected Mean Matrices

meanMZ ← mxMatrix( type=“Full”, nrow=1, ncol=ntv, free=TRUE, values=svm, labels=c(“mMZ1”,“mMZ2”), name=“meanMZ” )

meanDZ ← mxMatrix( type=“Full”, nrow=1, ncol=ntv, free=TRUE, values=svm, labels=c(“mDZ1”,“mDZ2”), name=“meanDZ” )

emeanMZ ← mxAlgebra( expression= meanMZ +betaS%\*%defSex +betaA%\*%cbind(defAge,defAge), name=“emeanMZ” )

emeanDZ ← mxAlgebra( expression= meanDZ +betaS%\*%defSex +betaA%\*%cbind(defAge,defAge), name=“emeanDZ” )
