Example Mx Script
Univariate ACE Twin Model
! Mx ACE script for twin data
#define nvar 1
Group1: Defines Matrices
Calc NGroups=4
Begin Matrices;
! path co-efficients
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
End Matrices;
Matrix H .5
Begin Algebra;
! variance matrices
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.5 Z 1 1 to Z nvar nvar
End
Group2: MZ twin pairs
Data NInput_vars=2 NObservations=1500
CMatrix
2.12
1.67 2.08
Labels trait1 trait2
Matrices= Group 1
Covariances A + C + E | A + C _
A + C | A + C + E /
Option RS
End
Group3: DZ twin pairs
Data NInput_vars=2 NObservations=2000
CMatrix
1.98
1.25 2.06
Labels trait1 trait2
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