!     
!  Maximum Likelihood Example
!
!     Bernstein data on ABO blood-groups
!     c.f. Edwards, AWF (1972)  Likelihood.  Cambridge Univ Press, pp. 39-41
!
#ngroups 1
ABO two locus
 Data NInput=1
 Begin Matrices;
  P Full 1 1 Free ! allele freq loc 1
  S Full 1 1 Free ! allele freq loc 2
  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 S 1 1
  Start .5 P 1 1  S 1 1
  
 Begin Algebra;
  Q = I - P;
  T = I - S;
  E = (P*P+D*P*Q)*T*T_
      (Q*Q)*(S*S+D*S*T)_
      (P*P+D*P*Q)*(S*S+D*S*T)_
      (Q*Q)*(T*T);
F=\sum(O)@E;
 End Algebra;

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

