Example Mx Script
Multivariate ACE Twin Model
! Mx ACE script for twin data
#define nvar 3
Group1: Defines Matrices
Data Calc NGroups=4
Begin Matrices;
X Lower nvar nvar free ! genetic structure
Y Lower nvar nvar free ! shared environment
Z Lower nvar nvar free ! non-shared environment
H Full 1 1
I Iden 4 4
End Matrices;
Matrix H .5
Begin Algebra;
A= X*X'; ! genetic covariance matrix
C= Y*Y'; ! environmental covariance matrix
E= Z*Z'; ! nonshared environmental covariance matrix
End Algebra;
Start 0 X 1 1 to X nvar nvar
Start 0 Y 1 1 to Y nvar nvar
Start 1.7 Z 1 1 to Z nvar nvar
End
Group2: MZ twin pairs
Data NInput_vars=6 NObservations=1500
CMatrix
4.24756
-.280441 3.39532
2.01213 .05206 2.95854
3.2865 -.243047 2.01504 4.39321
-.210246 2.38388 .096846 -.202754 3.42946
2.02091 .050704 2.44859 2.02949 .114946 2.86705
Labels x1 y1 z1 x2 y2 z2
Matrices= Group 1
Covariances A + C + E | A + C _
A + C | A + C + E /
Option RS
End
Group3: DZ twin pairs
Data NInput_vars=6 NObservations=2000
CMatrix
4.35496
-.354591 3.68418
2.04503 .097915 3.17886
2.12497 .329648 1.41837 4.15677
.241837 1.64101 .430632 -.216949 3.43144
1.34426 .501343 1.70592 2.01647 .139561 3.12658
Labels x1 y1 z1 x2 y2 z2
Matrices= Group 1
Covariances A + C + E | H@A + C _
H@A + C | A + C + E /
Option RS
End
Group4: Standardised solution
Calculation
Matrices = group 1
Begin Algebra;
! phenotypic covariance matrix
P = A + C + E;
! diagonal matrix of phenotypic
! standard deviations
D = \sqrt(\v2d(\d2v(P)));
! phenotypically standardised genetic
! covariance matrix
T = D~ * A * D~;
! phenotypically standardised shared
! environmental covariance matrix
U = D~ * C * D~;
! phenotypically standardised
! nonshared environmental covariance matrix
V = D~ * E * D~;
! Genetic correlation matrix
G = \stnd(T);
! Shared environmental correlation matrix
S = \stnd(U);
! Nonshared environmental correlation matrix
N = \stnd(V);
End Algebra;
End