! univariate_ascertained.mx
! fitting a univariate genetic model to 1x2 data from clinically
!  ascertained probands and their cotwins
#define nvar 1
#define maxthresf 1 ! number of thresholds
Analysis of Gurling alcohol dependence proband/cotwin data 
data NI=3 NG=3
LAbels twina twinb countmz
Ordinal fi=ascmzm.rec
! Count is a definition variable that we use to tell MX the frequency count
! for each element of the 2x2 table
!
Definition_variables countmz /
Begin matrices;
W LO nvar nvar fr ! additive genetic path (A=w*w')
X LO nvar nvar fr ! shared environmental path (C=x*x') 
Y LO nvar nvar fr ! non-shared environmental path (E=y*y') 
Z LO nvar nvar fi ! non-additive genetic path (D=z*z')
M FU maxthresf nvar fi ! matrix of thresholds
S DI nvar nvar    ! Matrix that will store weight variable
end matrices;
MATRIX M 1.96
! This tells MX to store the definition variable count in S
SP S
-1 
mat w 0.5
mat x 0.5 
mat y 0.7
Begin algebra;
A=W*W';
C=X*X';
E=Y*Y';
D=Z*Z';
V=A+C+D+E;
end algebra;
FREQ S; ! tells MX that S contains the weight (frequency) variable
TH M|M; ! tells MX that row and column thresholds contained in M_M
CO V|A+D+C_
   A'+D'+C'|V; ! formula for correlation matrix!
bo 0.001 1.0 y(1,1) 
bo 0.0001 0.999 w(1,1) x(1,1)
interval a(1,1) c(1,1) e(1,1) ! compute 95% confidence interval for correlation 
OPT func=1.E-12
OPT RS
END
Analysis of Gurling alcohol dependence data: DZm
data NI=3 
LAbels twina twinb countdz
OR fi=ascdzm.rec
Definition_variables countdz /
Begin matrices = group 1; 
S DI nvar nvar    ! Matrix that will store weight variable
g DI 1 1    ! constant (=0.5) for coefficient of additive genetic component
h DI 1 1    ! constant (=0.25) for coefficient of dominance genetic component 
n FU maxthresf nvar fi ! matrix of thresholds
end matrices;
MATRIX N 1.96
MAT g 0.5
MAT h 0.25
SP S
-1 
FREQ S;
TH N|N;
CO V|g@A+h@D+C_
   g@A'+h@D'+C'|V; ! formula for correlation matrix!
bo -5.0 5.0 n(1,1)
OPT RS
END
Constraint function - constrain variances to unity
CO NI=1
Begin matrices = group 1;
U unit 1 nvar
end matrices;
CO \d2v(V) = u;
end