!
! Ascertainment correction, estimating pi
!
G1: Model parameters
 Data Calc NGroups=2
 Begin Matrices;
  M Stan 2 2 Free
  H FUll 1 1 
  W Lower 1 1 
  O Zero 1 1
  P full 1 1 ! ascertainment probability p
  U unit 1 1
  T full 1 1
 End Matrices;
 ! parameters are fixed by default, unless declared free 
 Matrix H .5
 Matrix T 1.282
 Matrix P .9
 Begin Algebra;
  S= (P+P _ P _ P+P-P*P) ; ! Vector of ascertainment probabilities
  J= (P+P)*\mnor(U_O_T_T_U)-P*P*\mnor(M_O|O_T|T_T|T_U|U);
 End Algebra:
End

G2: Twin pairs
 Data Ninput=4
 Labels T1 T2 Asc Freq
 Ordinal File=rpi3.frq
 Definition Asc Freq ;
 Begin Matrices= Group 1
  F full 1 1 ! Frequency
  G full 1 4 ! to select ascertainment prob
 End Matrices;
 Specify F Freq
 Matrix G 1 1 1 1
 Specify G asc 0 asc 0
 Covariances M;
 Thresholds T|T ;
 Frequency F ;
 Weight \part(S,G)%J ;
 Options RSidual Multiple Issat
End 
  Value .1 P 1 1 1
End
