!     
!  Maximum Likelihood Example
!
!     Bernstein data on ABO blood-groups
!     c.f. Edwards, AWF (1972)  Likelihood.  Cambridge Univ Press, pp. 39-41
!
#ngroups 2
ABO single locus
 Data NInput=1
 Begin Matrices;
  P Full 1 1 Free ! allele freq 1
  Q Full 1 1 Free ! allele freq 2
  R Full 1 1 Free ! allele freq 3
  I Unit 1 1
  D Full 1 1
  O Full 4 1      ! observed data
 End Matrices;

  Matrix D 2
  Matrix O 212 103 39 148
 Bound 0 1 P 1 1 Q 1 1 R 1 1  
 Matrix P .6
 Ma Q .3
 Ma R .1
!Start .333 P 1 1 Q 1 1 R 1 1
 Begin Algebra;
  E = P*(P+D*R)_
      Q*(Q+D*R)_
      D*P*Q_
      R*R;
F=\sum(O)@E;
 End Algebra;

 Compute -\sum(\ln(E).O);
 Option User-Defined
End Group

Constraint Group
 Constraint NI=1
 Begin Matrices = (P1 Q1 R1 I1)
 End Matrices;

 Constraint I = P + Q + R;
 Option RS
End Group

