! SCRIPT NAME : example_ace.mx (dp) ! GOAL : To calculate variance components ! DATA : continuous ! INPUT : raw data ! UNI/BI/MULTI : uni ! DATA-GROUPS : MZM DZM MZF DZF DOSMF DOSFM ! MEANS MODEL : grand mean, sex effect !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #define nvar 1 ! For every instance of the word nvar in the script, ! Mx reads 1. This corresponds to one phenotype to be analysed #Define ndef 1 ! number of covariates (age and sex in this script) #Define nsib 2 !tells mx the size of the largest sibship G1: calculation group Data Calc NGroups=3 Begin matrices; X Lower nvar nvar Free ! additive genetic path coefficient (standard deviation) Y Lower nvar nvar Free ! common environmental path coefficient (standard deviation) Z Lower nvar nvar Free ! unique environmental path coefficient (standard deviation) H Full 1 1 fix ! .5 for dz cov A Q Full 1 1 fix ! for DZ cov if estimating C Q=1 if estimating D Q=.25 G Full 1 nsib free ! grand mean phenotypes P Full ndef nvar Free ! estimated effects of the covariates (sex age) End matrices; Matrix H .5 ! Matrix H is fixed and contains .5 Matrix Q 1 ! Matrix H is fixed and contains .5 Begin algebra; A= X*X' ; ! additive genetic variance C= Y*Y' ; ! common environmental variance E= Z*Z' ; ! unique environmental variance S = A%(A+C+E) | C%(A+C+E) | E%(A+C+E) ; !standardized variance components End algebra; st 6 X 1 1 1 ! provide starting values st 2 Y 1 1 1 st 2 Z 1 1 1 st .2 G 1 1 g 1 2 end G2: MZ twins, datagroup Data NInput_vars= 7 Missing=-9.00 REctangular file=simulated.dat LABELS zyg sex1 sex2 sex3 twin1 twin2 sib1 Select if zyg = 1 ; ! select mz Select sex1 sex2 twin1 twin2 ; Definition sex1 sex2 ; Matrices = group 1 N Full ndef nsib fix ! observed covariates End matrices; Specify N sex1 sex2 Means G+(N@P) ; ! model for means Covariances ! model for MZ variance/covariances A+C+E | A+C _ A+C | A+C+E ; Options RSiduals end G3: DZ twins, datagroup Data NInput_vars= 7 Missing=-9.00 REctangular file=simulated.dat LABELS zyg sex1 sex2 sex3 twin1 twin2 sib1 Select if zyg = 2 ; ! select mz Select sex1 sex2 twin1 twin2 ; Definition sex1 sex2 ; Matrices = group 1 N Full ndef nsib fix ! observed covariates End matrices; Specify N sex1 sex2 Means G+(N@P) ; ! model for means Covariances ! model for MZ variance/covariances A+C+E | H@A+C _ H@A+C | A+C+E ; Option multi jiggle issat ! Interval @95 U 1 1 1 U 1 1 2 U 1 1 3 end Save ACE.mxs ! AE model Drop Y 1 1 1 end get ace.mxs ! CE model Drop X 1 1 1 end ! E model Drop X 1 1 1 Drop Y 1 1 1 end