set prompt off
echo 
echo =====================================
echo Regression testing suite for Sib-pair 
echo This version: 2021-Dec-06
echo =====================================
echo 
set ple -1
echo
echo Testing printing and output:
echo
echo ========
echo Test 1
echo ========
echo
echo echo ABCDE
echo Expect ABCDE
echo ABCDE
echo
echo ========
echo Test 2
echo ========
echo
echo echo \\{ A \\}\\n  B
echo Expect \{ A \}
echo Expect B
echo \{ A \}\nB
echo
echo ========
echo Test 3
echo ========
echo
echo 1+1
echo Expect 2.
1+1
echo
echo ========
echo Test 4
echo ========
echo
echo "1+1"
echo Expect 10.0
"1+1"
echo
echo ========
echo Test 5
echo ========
echo
echo "1-2"
echo Expect 0.01
"1-2"
echo
echo ========
echo Test 6
echo ========
echo
echo "1 1"
echo Expect 11
"1 1"
echo
echo ========
echo Test 7
echo ========
echo
echo 1+"a/a"
echo Expect b/b
1+"a/a"
echo ========
echo Test 8
echo ========
echo
echo 1d---2
echo Expect 3.0
1d---2
echo
echo ========
echo Test 9
echo ========
echo
echo ABCDE
echo Expect ERROR: token "ABCDE" not recognised.
ABCDE
echo
echo ========
echo Test 10
echo ========
echo
echo 5.0E+04
echo Expect 50000.
5.0E+04
echo
echo Testing arithmetic:
echo
echo ========
echo Test 11
echo ========
echo
macro r=94906267
macro p=(%r - 2)
macro q=(%r - 1)
echo -log (abs (((%q + sqrt (%q * %q - %p * %r )) / %p - 1)- 2/%p)) / log(2)
echo Expect 26.4999999...
-log (abs (((%q + sqrt (%q * %q - %p * %r )) / %p - 1)- 2/%p)) / log(2)
echo
echo Similar in Scheme (complicated by q*q and p*r being exactly
echo   representable as long integers ie q*q-p*r is 0 if 64 bit float
echo   or 1 if 64 bit integers)
echo
eval (define r 94906267)
eval (define p (- r 2))
eval (define q (- r 1))
eval (/ (- (log (/ (abs (- (- (+ q (sqrt (- (* q q) (* p r))) p) 1) (/ 2 p)))))) (log 2))
macro minpos = "4.94065646-324"
echo
echo (%minpos+%minpos)/%minpos
echo Expect 2.0
(%minpos+%minpos)/%minpos
eval (define minpos 4.94065646e-324)
eval (/ (+ minpos minpos) minpos)
echo
echo Testing functions:
echo
macro xx=1.3
macro yy=0.6
echo
echo ========
echo Test 12
echo ========
echo
echo abs(log(%xx)/log(10.)-log10(%xx)) 
echo Expect ~ eps (usually 2.22E-016)
abs(log(%xx)/log(10.)-log10(%xx)) 
echo
echo ========
echo Test 13
echo ========
echo
echo abs(tan(%xx+%yy)-(tan(%xx)+tan(%yy))/(1-tan(%xx)*tan(%yy)))
echo Expect ~ eps (usually 2.22E-016)
abs(tan(%xx+%yy)-(tan(%xx)+tan(%yy))/(1-tan(%xx)*tan(%yy)))
echo
echo ========
echo Test 14
echo ========
echo
echo abs(asin(sin(%xx))-%xx)
echo Expect 0.0
abs(asin(sin(%xx))-%xx)
echo
echo ========
echo Test 15
echo ========
echo
echo abs(acos(cos(%xx))-%xx)
echo Expect 0.0
abs(acos(cos(%xx))-%xx)
echo
echo ========
echo Test 16
echo ========
echo
echo abs(atan(tan(%xx))-%xx)
echo Expect 0.0
abs(atan(tan(%xx))-%xx)
echo
echo Testing date utilities:
echo
echo ========
echo Test 17
echo ========
echo
echo julian 19700101
echo Expect 0.0
julian 19700101
echo set epoch julian
set epoch julian
echo julian 19700101
echo Expect 2440588
julian 19700101
echo
echo ========
echo Test 18
echo ========
echo
echo int((julian 20070416 - julian 19651204)/365.25)
echo Expect 41
int((julian 20070416 - julian 19651204)/365.25)
echo
echo Testing statistical and genetic utilities:
echo
echo Expected results usually from the equivalent R command
echo
echo ========
echo Test 19
echo ========
echo
echo pnorm {-20 -15 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 15 20}
echo Expect  [1] 1.0000000000000000000e+00 1.0000000000000000000e+00
echo Expect  [3] 1.0000000000000000000e+00 1.0000000000000000000e+00
echo Expect  [5] 9.9999999999999933387e-01 9.9999999999872013490e-01
echo Expect  [7] 9.9999999901341229958e-01 9.9999971334842807646e-01
echo Expect  [9] 9.9996832875816688002e-01 9.9865010196836989653e-01
echo Expect [11] 9.7724986805182079141e-01 8.4134474606854292578e-01
echo Expect [13] 5.0000000000000000000e-01 1.5865525393145704647e-01
echo Expect [15] 2.2750131948179208585e-02 1.3498980316300945772e-03
echo Expect [17] 3.1671241833119924327e-05 2.8665157187919391185e-07
echo Expect [19] 9.8658764503769809052e-10 1.2798125438858351639e-12
echo Expect [21] 6.2209605742717848604e-16 1.1285884059538407827e-19
echo Expect [23] 7.6198530241605269199e-24 3.6709661993127508291e-51
echo Expect [25] 2.7536241186062337371e-89
pnorm {-20 -15 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 15 20}
echo
echo ========
echo Test 20
echo ========
echo
echo pch { 1 3 12 20 43 100 200 } 2
echo Expect [1] 6.065307e-01 2.231302e-01 2.478752e-03 4.539993e-05 4.599055e-10
echo Expect [6] 1.928750e-22 3.720076e-44
pch { 1 3 12 20 43 100 200 } 2
echo
echo ========
echo Test 21
echo ========
echo
echo pch { 1 3 12 20 43 100 200 } 2 ncp 3
echo Expect [1] 8.781745e-01 6.215002e-01 6.345203e-02 5.180278e-03 1.394612e-06
echo Expect [6] 1.659037e-16
pch { 1 3 12 20 43 100 200 } 2 ncp 3
echo
echo ========
echo Test 22
echo ========
echo
echo qch { 6.065307e-01 2.231302e-01 2.478752e-03 4.539993e-05 4.599055e-10 1.928750e-22 3.720076e-44 } 2
echo Expect 1 3 12 20 43 100 200 
qch { 6.065307e-01 2.231302e-01 2.478752e-03 4.539993e-05 4.599055e-10 1.928750e-22 3.720076e-44 } 2
echo
echo ========
echo Test 23
echo ========
echo
echo from example(davies) in CompQuadForm R packageaof P Lafaye de Michaux
echo
echo (- 1 (pchisqsum 1 '(6 3 1)))
echo Expect 1 - davies(1, c(6, 3, 1), c(1, 1, 1))$Qq   => 0.05421295
echo Expect 1 - davies(7, c(6, 3, 1), c(1, 1, 1))$Qq   => 0.4935552
echo Expect 1 - davies(20, c(6, 3, 1), c(1, 1, 1))$Qq  => 0.8760272
echo Expect 1 - davies(50, c(6, 3, 1), c(1, 1, 1))$Qq  => 0.9934544
echo Expect 1 - davies(100, c(6, 3, 1), c(1, 1, 1))$Qq => 0.9999265
eval (map (lambda (x) (- 1 (pchisqsum x '(6 3 1)))) '(1 7 20 50 100))
echo Expect  davies(150, c(6, 3, 1), c(1, 1, 1))$Qq      => 6.375044e-06
echo Expect  imhof(150, c(6, 3, 1),  c(1, 1, 1))$Qq      => 9.779262e-07
echo Expect  farebrother(150, c(6, 3, 1), c(1, 1, 1))$Qq => 9.100371e-07
echo Expect  liu(150, c(6, 3, 1), c(1, 1, 1))            => 4.367912e-07
eval (pchisqsum 150 '(6 3 1))
echo Expect  davies(200, c(6, 3, 1), c(1, 1, 1))$Qq      => 0
echo Expect  imhof(200, c(6, 3, 1),  c(1, 1, 1))$Qq      => -1e-7
echo Expect  farebrother(200, c(6, 3, 1), c(1, 1, 1))$Qq => 1.229842e-08
echo Expect  liu(200, c(6, 3, 1), c(1, 1, 1))            => 3.729682e-09
eval (pchisqsum 200 '(6 3 1))
echo
echo ========
echo Test 24
echo ========
echo
sml 0.17 0.21 0.08 0.03
echo
echo ========
echo Test 25
echo ========
echo
grr 0.1 0.2 0.1 case
echo
echo ========
echo Test 26
echo ========
echo
echo tetrachoric correlations corresponding to 
echo   p=0.1 OR=1.1 1.2 1.5 2 3 4 5 6 7 10
echo
tet 0.1 {1.1 1.2 1.5 2 3 4 5 6 7 10}
echo
echo ========
echo Test 27
echo ========
echo
ito 0.01 0.5 0.5 0.0
echo
echo Testing logical and comparative operations:
echo
echo ========
echo Test 28
echo ========
echo
echo 1 == 1.0d0
echo Expect 1.0
1 == 1.0d0
echo
echo ========
echo Test 29
echo ========
echo
echo 1 ^= 1.0d0
echo Expect 0.0
1 ^= 1.0d0
echo
echo ========
echo Test 30
echo ========
echo
echo "a/a" == "a/a"
echo Expect 1.0
"a/a" == "a/a"
echo
echo ========
echo Test 31
echo ========
echo
echo "a/a" == "a/b"
echo Expect 0.0
"a/a" == "a/b"
echo
echo ========
echo Test 32
echo ========
echo
echo "a/a" ^= "a/b"
echo Expect 1.0
"a/a" ^= "a/b"
echo
echo ========
echo Test 33
echo ========
echo
echo "a/a" ^= "a/a"
echo Expect 0.0
"a/a" ^= "a/a"
echo
echo ========
echo Test 34
echo ========
echo
echo "a/a" < "a/a"
echo Expect 0.0
"a/a" < "a/a"
echo ========
echo Test 35
echo ========
echo "a/a" < "a/b"
echo Expect 1.0
"a/a" < "a/b"
echo
echo ========
echo Test 36
echo ========
echo
echo "a/a" > "a/b"
echo Expect 0.0
"a/a" > "a/b"
echo
echo Testing string searches:
echo
clear
set seeds 12345 12345 12345
read ped inline
a             with          x x x 
alia          were          x x x 
are           viewed        x x x 
as            variables     x x x 
at            up            x x x 
be            top           x x x 
between       to            x x x 
Both          they          x x x 
bottom        then          x x x 
but           the           x x x 
cannot        than          x x x 
ceiling       strongly      x x x 
combined      strong        x x x 
originally    pile          x x x 
pile          originally    x x x 
strong        combined      x x x 
strongly      ceiling       x x x 
than          cannot        x x x 
the           but           x x x 
then          bottom        x x x 
they          Both          x x x 
to            between       x x x 
top           be            x x x 
up            at            x x x 
variables     as            x x x 
viewed        are           x x x 
were          and           x x x 
with          a             x x x 
;;;;
run
echo
echo ========
echo Test 37
echo ========
echo
set echo on
print ped a
set echo off
echo
echo ========
echo Test 38
echo ========
echo
set echo on
print ped *h
set echo off
echo
echo ========
echo Test 39
echo ========
echo
set echo on
print ped *h*
set echo off
echo
echo ========
echo Test 40
echo ========
echo
set echo on
print ped * id a.. 
set echo off
echo
echo ========
echo Test 41
echo ========
echo
set echo on
print ped * id *i*i*l
set echo off
echo
echo ========
echo Test 42
echo ========
echo
set echo on
select id a* b*t* w*
set echo off
wri
clear
echo
echo ========
echo Test 43
echo ========
echo
echo Newer categorical data handling 
echo
clear
set loc m1 mar 
set loc n1 qua numeric
set loc n2 cat numeric
set loc a cat stringy
set loc b cat same but numeric
set ple 3
read cases inline noid
2/2   2  2  second      2
23/23 23 23 "two three" "2 3"
3/3   3  3  third       3
4/4   4  4  fourth      4
2/2   2  2  second      2
1/1   1  1  first       1
1/1   1  1  first       1
x/x   x  x  x           x
;;;;
run
wri
set ple 0 silent
clear
set loc m1 mar 
set loc n1 qua numeric
set loc n2 cat numeric
set loc a cat stringy
set loc b cat same but numeric
set ple 3
read pedigree inline 
1 1 3 4 f 2/2   2  2  second      2
1 2 3 4 m 23/23 23 23 "two three" "2 3"
1 3 x x f 3/3   3  3  third       3
1 4 x x m 4/4   4  4  fourth      4
2 1 x x m 2/2   2  2  second      2
2 2 x x f 1/1   1  1  first       1
2 3 1 2 m 1/1   1  1  first       1
2 4 x x x x/x   x  x  x           x
;;;;
set che off
set imp -1
set ple 3
run
wri
set ple 0 silent
eval (locnotes-set! "b" " ")
set cat labels
set tab |
write
eval (locnotes-set! "b" "2=Two")
write
set tab " "
clear
#
# Recoding
#
echo
echo Testing data recoding:
echo
set loc a mar
set loc b qua
read cases inline
1 A/B 21.3
2 1/2 123
3 B/C 1
4 2/4 1.00001
5 D/3 99
;;;;
run
write
recode a 1 2 3 D to A B C x
recode b 1 123 to 42.42
set nde 10 5
echo
echo ========
echo Test 44
echo ========
echo
write
set nde 9 4
clear
#
# File manipulation etc
#
echo
echo Testing file manipulation etc:
echo
echo
echo ========
echo Test 45
echo ========
echo
output mat1.txt
echo A B C
echo A B C D
echo A B
echo A 
output
set misval .
set plevel 1
file query mat1.txt
file wc mat1.txt
file head mat1.txt 2
file cat mat1.txt
file transpose mat1.txt
set plevel 0
file delete mat1.txt
set misval x

set seeds 12345 12345 12345
set loc a mar
read cases inline
1 x/x
2 A/A
3 A/B
4 B/B
5 x/x
;;;;
run
set loc b qua
output update.dat
echo #
echo # Example update dataset
echo # 
echo ped id b a z
echo 1 1 1 C/C 9
echo 2 2 2 C/C 9
echo #
echo # Person 3
echo #
echo 3 3 3 A/B x
echo 4 4 4 B/B x
echo 5 5 5 C/C 9
echo 6 6 6 Z/Z 9
output
echo
echo ========
echo Test 46
echo ========
echo
echo Contents of Update file:
file cat update.dat
echo
echo ========
echo Test 47
echo ========
echo
echo Original file
echo
write
update a update.dat
echo
echo ========
echo Test 48
echo ========
echo
echo After updating a
echo
write
update a b update.dat
echo
echo ========
echo Test 49
echo ========
echo
echo
echo After updating a and b
echo
write
set loc z qua
update z update.dat
echo
echo ========
echo Test 50
echo ========
echo
write

file delete update.dat
clear 

echo
echo Merging bed files
echo
set loc snp1 snp 1.0
set loc snp2 snp 2.0
set loc snp3 snp 3.0
set loc snp4 snp 4.0
read cases inline
1 A/A C/C E/F G/G
2 A/B C/C E/F G/H
3 B/B C/D F/F H/H
4 A/A C/D F/F G/G
5 A/B D/D E/E G/H
6 B/B D/D E/E H/H
;;;;
run
set chr 1
write
write plink snpAB
keep 1 -- 2
write plink snpA
und 
keep 3 -- 4
write plink snpB
drop
pack
echo =========
echo Test 51
echo =========
merge plink snpAB
list
write
drop
pack 
echo =========
echo Test 52
echo =========
merge plink snpA
list
write
echo =========
echo Test 53
echo =========
merge plink snpB
list
write
echo =========
echo Test 54
echo =========
delete snp1 snp2 snp3 snp4 where 1
order snp3 snp1 snp4 snp2
merge plink snpA
merge plink snpB
write
file delete snp{A B AB}.{bed bim fam}
clear
echo 
echo Pedigree rewriting, subpedigree and nuclear:
echo =========
echo Test 55
echo =========
echo 
set twin mzdz merlin
set loc mzdz qua
read pedigree inline
1 1 3 4 m 1
1 2 3 4 m 1
1 5 7 4 m 2
1 6 8 4 f 2
;;;;
run
write
subpedigree
write
echo 
echo File compression:
echo 
echo
echo ========
echo Test 56
echo ========
echo
!
output data.txt
echo C
echo B
echo A
output
$ gzip data.txt
echo
echo ========
echo Test 57
echo ========
echo
file cat data.txt.gz
file delete data.txt.gz
echo
echo ========
echo Test 58
echo ========
echo
write filetest1.ped
write bin filetest.bin
clear
echo
echo ========
echo Test 59
echo ========
echo
read bin filetest.bin
write filetest2.ped
set ple -2 silent
eval (define (same file1 file2) \
 (begin \
   (define p1 (open-input-file file1)) \
   (define p2 (open-input-file file2)) \
   (let loop ((lin1 (read-line p1)) \
              (n1 1) \
              (lin2 (read-line p2)) \
              (n2 1)) \
      (if (and (string? lin1) (string? lin2))  \
         (if (string=? lin1 lin2) \
            (loop (read-line p1) \
                  (+ n1 1) \
                  (read-line p2) \
                  (+ n2 1)) \
            (begin (display "Different at: ") \
                   (display (string=? lin1 lin2)) \
                   (newline) \
                   (display n1) (display ":") (display lin1) \
                   (newline) \
                   (display n2) (display ":") (display lin2) \
                   (newline))) \
         (if (and (equal? lin1 lin2) (not lin1)) \
            (begin \
              (display "Files ") \
              (write file1) \
              (display " and ") \
              (write file2) \
              (display " are the same") \
              (newline)) \
            (begin (display "One file shorter!") (newline))))) \
   (close-input-port p1) \
   (close-input-port p2)))
set ple -1
eval (same "filetest1.ped" "filetest2.ped")
file delete filetest.bin filetest1.ped filetest2.ped

clear
echo
echo Testing reading, writing, deleting files and Scheme scripting:
echo
echo ========
echo Test 60
echo ========
echo
eval (define (ranint n) \
  (let loop ((i 1))  \
     (if (<= i n)  \
        (begin  \
          (display (random 10000000)) (newline) \
          (loop (+ i 1)))  \
        (newline))))
macro ranfam
  output %%
  eval (ranint %1)
  output
  read cases %%
  run
  file delete %%
  output hash.out
  hash size 96
  output
;;;;
set seeds 12345 12345 12345
ranfam 2872
clear
ranfam 2872
clear
ranfam 2872
clear
ranfam 2872
clear
ranfam 2872
clear
echo
echo Testing hashing:
echo
file cat hash.out
out cleanhash.out
file print /Hashed/ NR 2 5 hash.out
out
dec loc 2q
read case cleanhash.out
run
echo
echo ========
echo Test 61
echo ========
echo
set loc probes qua
(probes = (trait1+trait2)/trait1)
echo
echo ======================================================================
echo Luo and Heileman IEICE Electronic Express 2004\; 1:150-155 found that
echo "improved exponential hashing" gave 3.33 probes per key
echo for 95\% loaded tables with 3023 buckets filled by random keys
echo ======================================================================
echo
mean probes
echo
file delete hash.out cleanhash.out
clear
#
# test the copy command
#
echo
echo Testing the copy command:
echo
set loc a mar
set loc b mar
read cases inline
1 x/x C/C
2 A/A x/x
3 A/B x/x
4 B/B x/x
5 x/x x/x
;;;;
run
echo
echo ========
echo Test 62
echo ========
echo
copy 3 3 4 4 merge
write
echo
echo ========
echo Test 63
echo ========
echo
copy 3 3 4 4 
write
echo
echo ========
echo Test 64
echo ========
echo
copy 1 1 2 2 
write
clear
echo
echo Testing linear models:
echo
#
# test dataset for regression algorithms from Longley 1967
#  Longley, J. W. (1967).  
#                An Appraisal of Least Squares Programs for the 
#                Electronic Computer from the Viewpoint of the User.
#                Journal of the American Statistical Association, 62, pp.
#                819-841.
#
set loc GNP.deflat qua
set loc GNP        qua
set loc Unemployed qua
set loc Armed.Forc qua
set loc Population qua
set loc Year       qua
set loc Employed   qua
read cases inline
! GNP.deflator  GNP   Unemployed Armed.Forces Population Year Employed
1  83.0  234.289 235.6 159.0 107.608 1947 60.323 
2  88.5  259.426 232.5 145.6 108.632 1948 61.122 
3  88.2  258.054 368.2 161.6 109.773 1949 60.171 
4  89.5  284.599 335.1 165.0 110.929 1950 61.187 
5  96.2  328.975 209.9 309.9 112.075 1951 63.221 
6  98.1  346.999 193.2 359.4 113.270 1952 63.639 
7  99.0  365.385 187.0 354.7 115.094 1953 64.989 
8  100.0 363.112 357.8 335.0 116.219 1954 63.761 
9  101.2 397.469 290.4 304.8 117.388 1955 66.019 
10 104.6 419.180 282.2 285.7 118.734 1956 67.857 
11 108.4 442.769 293.6 279.8 120.445 1957 68.169 
12 110.8 444.546 468.1 263.7 121.950 1958 66.513 
13 112.6 482.704 381.3 255.2 123.366 1959 68.655 
14 114.2 502.601 393.1 251.4 125.368 1960 69.564 
15 115.7 518.173 480.6 257.2 127.852 1961 69.331 
16 116.9 554.894 400.7 282.7 130.081 1962 70.551 
;;;;
run
echo
echo ==========================================================
echo The NIST results are:
echo            Beta                    Standard Error
echo
echo Intercept  -3482.25863459582       890.420383607373    
echo GNP.deflat     0.0150618722713733    0.0849149257747669  
echo GNP           -0.0358191792925910    0.0334910077722432  
echo Unemployed    -0.0202022980381683    0.00488399681651699 
echo Armed.Forc    -0.0103322686717359    0.00214274163161675 
echo Population    -0.0511041056535807    0.226073200069370   
echo Year           1.82915146461355      0.455478499142212   
echo
echo Model Mean Square 30.6954003240823
echo Mean Square Error  0.0929360061673238
echo R-Squared          0.995479004577296
echo ==========================================================
echo
echo ========
echo Test 65
echo ========
regress Employed on GNP.deflat GNP Unemployed Armed.Forc Population Year 
echo
echo
echo =================================================================================
echo For principal components analysis, R princomp() gives:
echo Eigenvectors:
echo
echo  5.5330676785 1.1875546443 0.2522163113 0.0152385220 
echo  0.0106362646 0.0010279413 0.0002586380 
echo Eigenvalues:
echo -0.4225559  0.03331479  0.04154777  0.68544289  0.5384123 -0.22754105 -0.08435441
echo -0.4232763  0.03003906  0.15667625 -0.18863757  0.2148123  0.50920350  0.67407027
echo -0.2791521 -0.61726052 -0.67738968  0.07297657 -0.2248161 -0.06320698  0.14947835
echo -0.1887305  0.77656258 -0.58598762 -0.04866667 -0.1046508 -0.05290781  0.04278298
echo -0.4218501 -0.06924115  0.08434184 -0.66741256  0.2739382 -0.51075414 -0.16965609
echo -0.4247835 -0.02365912  0.03157581 -0.04933020 -0.1339253  0.57803987 -0.68081026
echo -0.4127227  0.09259423  0.40419980  0.19752696 -0.7137896 -0.29519928  0.14850470
echo
echo =================================================================================
echo 
echo ========
echo Test 66
echo ========
echo 
pca
clear
echo
echo
echo Testing permutation contingency chi-square:
echo
#
# Sparse table from Mehta et al J Classification 1990; 7:111-4
# Exact Pearson X2 P= 0.0013 (StatXact) or 0.0015 (fisher.test)
# Sib-pair, by contrast, uses the LRTS (Gibbs X2).
#
# Second table from Mehta and Patel (1983), and used by 
# Newton and Geyer (1994), and Davison and Hinkley (1997)
# fisher.test() gives P=0.03929
#
set iter 1000
chi 3 9
0 7 0 0 0 0 0 1 1 
1 1 1 1 1 1 1 0 0 
0 8 0 0 0 0 0 0 0 
chi 5 7
1 2 2 1 1 0 1
2 0 0 2 3 0 0
0 1 1 1 2 7 3
1 1 2 0 0 0 1
0 1 1 1 1 0 0
set iter 200

clear
echo
echo
echo Testing Kruskal-Wallis test:
echo
#
# Kruskal-Wallis test
#
set loc treatment qua
set loc response qua
read cas inline
1   1 2
2   1 3
3   1 3
4   1 3
5   1 3
6   1 0
7   2 1
8   2 3
9   2 1
10  2 2
11  2 2
12  2 3
13  3 3
14  3 1
15  3 2
16  3 1
17  3 3
18  3 3
19  4 1
20  4 0
21  4 0
22  4 0
23  4 0
24  4 -1
;;;;
run
echo
echo ========
echo Test 67
echo ========
echo
recast response cat
tab treatment response
recast response cat
echo
echo ========
echo Test 68
echo ========
echo
echo ====================================================
echo Rosner B.  Fundamentals of Biostatistics 3rd edition
echo Example 12.21   H = 11.806 df = 3 P = 0.008078148
echo
echo Data from Abelson et al (1983)
echo
echo ====================================================
kru response treatment

echo
echo
echo Testing survival analysis:
echo

clear
set loc time qua
set loc stadium qua
set loc event aff
read cases inline
# id time stadium event 
1  28   1 y 
2  89   1 y 
3  175  1 y 
4  195  1 y 
5  309  1 y 
6  377  1 n 
7  393  1 n 
8  421  1 n 
9  447  1 n 
10 462  1 y 
11 709  1 n 
12 744  1 n 
13 770  1 n 
14 1106 1 n 
15 1206 1 n 
16 34   2 y 
17 88   2 y 
18 137  2 y 
19 199  2 y 
20 280  2 y 
21 291  2 y 
22 299  2 n 
23 300  2 n 
24 309  2 y 
25 351  2 y 
26 358  2 y 
27 369  2 y 
28 369  2 y 
29 370  2 y 
30 375  2 y 
31 382  2 y 
32 392  2 y 
33 429  2 n 
34 451  2 y 
35 1119 2 n 
;;;;
run
echo
echo ========
echo Test 69
echo ========
echo
set ple 0
kaplan-meier time event
echo
echo ========
echo Test 70
echo ========
echo
reg time = stadium weibull event
echo
echo Note that dummy does not exist: kludge to fit intercept only model!
echo
reg time = dummy weibull event
lrt
echo
echo ========
echo Test 71
echo ========
echo
lifetest 0 time event tim cov stadium
echo
echo ========
echo Test 72
echo ========
echo
surv time event stadium
echo
echo Survival analysis of pedigree data:
echo Cai et al. APOE is linked to Alzheimer's disease in a large pedigree.
echo Am J Med Genet (Neuropsychiatr Genet) 1997\; 74: 365-69.
echo
clear
set locus AD aff
set locus AD50 aff
set locus onset qua
set locus age qua
set locus apoe marker
set locus apoc1 marker
read pedigree inline
1 101 x   x   m x x x  x  x x x x 
1 102 x   x   f x x x  x  x x x x 
1 201 101 102 m y y 57 x  3 4 1 1 
1 202 x   x   f n n x  x  3 4 1 1 
1 203 101 102 f y y 62 x  x x x x 
1 204 x   x   m n n x  x  x x x x 
1 206 x   x   f n n x  x  x x x x 
1 205 101 102 m y y 65 65 x x x x 
1 207 101 102 m n n x  x  x x x x 
1 208 x   x   f n n x  x  x x x x 
1 209 101 102 m n n x  x  x x x x 
1 210 x   x   f n n x  x  x x x x 
1 211 x   x   m n n x  x  x x x x 
1 301 201 202 m n n x  x  x x x x 
1 302 201 202 m n n 74 74 3 3 1 1 
1 336 x   x   f n n x  x  x x x x 
1 304 x   x   m n n x  x  x x x x 
1 305 201 202 f y y 54 x  4 4 1 1 
1 306 201 202 m n n x  x  x x x x 
1 316 205 206 m y y 69 x  3 4 1 1 
1 315 x   x   f n n x  x  x x x x 
1 317 205 206 f n n x  x  x x x x 
1 341 x   x   m n n x  x  x x x x 
1 318 205 206 f n n x  x  x x x x 
1 337 x   x   m n n x  x  x x x x 
1 319 205 206 f n n x  x  x x x x 
1 321 x   x   f n n x  x  x x x x 
1 320 205 206 m y y x  x  x x x x 
1 322 205 206 m n n x  x  x x x x 
1 323 205 206 m n n x  x  x x x x 
1 338 209 210 m n n 73 73 3 3 1 1 
1 339 x   x   f n n x  x  x x x x 
1 340 209 210 m n n 75 75 3 3 1 1 
1 342 211 210 f n n 62 62 3 3 1 1 
1 343 x   x   m n n x  x  x x x x 
1 419 302 336 m n n x  x  x x x x 
1 420 302 336 m n n x  x  x x x x 
1 401 x   x   m n n x  x  3 3 1 1 
1 402 304 305 f n x 46 46 3 4 1 1 
1 403 x   x   m n n x  x  x x x x 
1 404 304 305 f n x 45 45 3 4 1 1 
1 405 304 305 m n x 44 44 3 4 1 1 
1 446 316 315 f n x 49 49 3 4 1 2 
1 413 316 315 m n n 62 62 3 3 1 1 
1 423 316 315 m n n x  x  x x x x 
1 424 316 315 f n x 50 50 2 4 1 2 
1 439 341 317 m n n x  x  x x x x 
1 440 341 317 m n n x  x  x x x x 
1 442 341 317 f n n x  x  x x x x 
1 425 337 319 m n n x  x  x x x x 
1 426 320 321 m n n x  x  x x x x 
1 427 320 321 m n n x  x  x x x x 
1 428 320 321 m n n x  x  x x x x 
1 437 338 339 m n n 54 54 3 3 1 1 
1 438 338 339 f n n x  x  x x x x 
1 445 343 342 m n x 46 46 3 3 1 1 
1 307 x   x   m n n x  x  x x x x 
1 308 204 203 f n n 65 65 3 4 1 1 
1 309 204 203 m y y 64 x  4 4 1 1 
1 310 x   x   f n n x  x  3 4 1 1 
1 311 204 203 f y y 59 x  x x x x 
1 312 x   x   m n n x  x  3 4 1 1 
1 313 204 203 m n n x  x  x x x x 
1 314 x   x   f n n x  x  2 3 1 1 
1 325 207 208 f y y x  x  x x x x 
1 324 x   x   m n n x  x  x x x x 
1 327 207 208 m y y 65 x  x x x x 
1 326 x   x   f n n x  x  x x x x 
1 328 207 208 m y y 60 x  x x x x 
1 329 x   x   f n n x  x  x x x x 
1 331 207 208 f x x 74 74 3 3 1 1 
1 330 x   x   m n n x  x  x x x x 
1 333 207 208 f n n x  x  x x x x 
1 334 207 208 m n n x  x  x x x x 
1 335 x   x   f n n x  x  x x x x 
1 406 307 308 f n x 45 45 3 4 1 1 
1 407 307 308 m n x 44 44 3 4 1 1 
1 408 309 310 m n x 46 46 3 4 1 1 
1 409 312 311 m n x 39 39 3 3 1 1 
1 410 312 311 f n x 35 35 3 4 1 1 
1 411 313 314 m n n x  x  x x x x 
1 412 313 314 m n n x  x  x x x x 
1 429 324 325 f n n x  x  x x x x 
1 430 324 325 f n n x  x  x x x x 
1 431 324 325 f n n x  x  x x x x 
1 432 324 325 f n n x  x  x x x x 
1 433 327 326 f n n x  x  x x x x 
1 434 327 326 m n n x  x  x x x x 
1 416 328 329 f n n x  x  x x x x 
1 415 x   x   m n n x  x  x x x x 
1 435 328 329 f n n x  x  x x x x 
1 436 330 331 f n x 46 46 3 3 1 1 
1 443 330 331 m n n 58 58 3 3 1 1 
1 418 330 331 f n n 60 60 3 3 1 1 
1 417 x   x   m n n x  x  3 4 1 1 
1 444 334 335 f n x 50 50 3 3 1 1 
1 501 415 416 m n x 26 26 2 3 1 1 
1 502 415 416 f n x 27 27 3 3 1 1 
1 503 417 418 m n x 35 35 3 3 1 1 
1 504 403 404 m n n x  x  x x x x 
;;;;
run
echo
echo ========
echo Test 73
echo ========
echo
surv onset AD
echo
echo Testing categorical trait gene-dropping association:
echo
clear
set loc a qua
set loc b mar
read cases inline
1 1 1/1
2 2 x/x
3 1 1/2
4 3 1/2
5 3 1/2
6 1 1/1
7 1 1/1
8 1 1/1
9 1 1/1
;;;;
run
echo
echo ========
echo Test 74
echo ========
echo
set ple 1
ass a cat
set ple -1
clear
echo 
echo Testing handling of twins:
echo 
set locus zyg qua
set locus mar marker
set locus qtrait qua
set twin zyg merlin
read pedigree inline
1 1 x x m x 1/1 10
1 2 x x f x 1/2 20
1 3 1 2 m 1 1/1 11
1 4 1 2 m 1 1/2 10
1 5 x x f x 1/2 19
1 6 x x f x 1/2 22
1 7 3 5 f x 1/1 11
1 8 4 6 f 2 1/1 9 
1 9 4 6 m 2 1/2 18
2 3 1 2 m 1 1/1 11
2 4 1 2 m 1 x/x x 
2 5 4 6 m x 2/2 8 
;;;;
set error_drop on
run
echo
echo ========
echo Test 75
echo ========
echo
wri
echo
echo ========
echo Test 76
echo ========
echo
kinship 
echo
echo ========
echo Test 77
echo ========
echo
var qtrait
echo
echo ========
echo Test 78
echo ========
echo
var qtrait cov mar
clear
echo
echo Testing sex:
echo
set locus AMELXY marker
set locus xmarker xmarker
read pedigree inline
1 1 x x m C/G 1/2
1 2 x x f C/G 3/4
1 3 x x m C/C 5/5
1 4 x x f C/C 6/6
;;;;
set che off
run
set sex marker AMELXY
test sex
clear
echo
echo Testing various genetic analyses:
echo
echo 
echo Pedigrees from the online supplementary data 
echo (http://www.gene.ucl.ac.uk/anhumgen/web2.doc) for
echo Cavanaugh JA et al (1998).
echo Analysis of Australian Crohn's disease pedigrees refines the localisation for
echo susceptibility to inflammatory bowel disease on chromosome 16.
echo Ann Hum Genet 62: 291-298.
echo 
set seeds 4576 123 2354 
set loc ibd      aff   .               
set loc D16S769  mar 53.713 26066263 (chr 16) 
set loc D16S3145 mar 55.012 26784604 (chr 16) 
set loc D16S753  mar 60.125 31181005 (chr 16) 
set loc D16S409  mar 60.998 47333369 (chr 16) 
set loc D16S411  mar 62.226 48294236 (chr 16) 
#       CARD15              49139742-49399041
set loc D16S419  mar 67.694 51510863 (chr 16) 
set loc D16S415  mar 69.148 52228236 (chr 16) 
set loc D16S771  mar 70.852 53066505 (chr 16) 
read pedigree inline
#--- Page 1 a-i ----
1a 1 x x m n 3/4 3/4 3/5   1/3  3/5 4/5 7/8  x/x  
1a 2 x x f n 4/5 4/8 4/5   1/6  4/7 3/5 4/8  x/x  
1a 3 1 2 f y 4/4 4/4 4/5   3/6  3/4 4/5 4/7  1/4  
1a 4 1 2 f y 4/5 4/4 4/5   3/6  3/4 4/5 4/7  1/4  
1b 1 x x m n 1/4 2/4 3/4   3/6  2/3 1/7 4/9  x/x  
1b 2 x x f n 4/4 2/2 1/5   3/3  4/5 5/5 2/4  1/3  
1b 3 1 2 f y 1/4 2/2 1/3   3/6  2/4 5/7 2/4  3/5  
1b 4 1 2 f y 1/4 2/2 1/3   3/6  2/5 5/7 2/4  3/5  
1c 1 x x m n x/x 2/4 3/6   x/x  x/x x/x x/x  x/x  
1c 2 x x f n 2/5 4/5 4/6   3/6  2/4 5/7 4/8  3/4  
1c 3 1 2 f y 3/5 4/4 6/6   2/3  4/4 1/5 4/8  3/4  
1c 4 1 2 f y 3/5 2/4 3/6   2/3  4/4 1/5 4/8  3/4  
1d 1 x x m n 4/4 4/4 3/5   3/6  2/3 5/7 3/7  1/4  
1d 2 x x f n 4/5 4/6 3/5   3/8  2/3 1/5 3/8  4/5  
1d 3 1 2 f y 4/4 4/6 3/3   3/6  3/3 1/7 3/8  4/4  
1d 4 1 2 f y 4/4 4/6 3/3   3/6  3/3 1/7 3/7  4/5  
1e 1 x x m n 3/5 x/x x/x   x/x  3/4 x/x 3/8  x/x  
1e 2 x x f n 3/4 4/5 4/5   3/4  3/4 3/5 3/6  3/4  
1e 3 1 2 f y 3/4 4/5 4/6   3/3  3/3 3/5 3/8  3/5  
1e 4 1 2 f y 3/3 4/4 5/6   3/4  3/3 3/5 3/8  3/5  
1e 5 1 2 f y 3/5 4/4 4/5   3/4  3/4 5/5 3/6  4/5  
1f 1 x x m n 3/4 4/7 4/4   3/3  1/3 5/6 8/10 3/4  
1f 2 x x f y 3/4 2/4 2/6   2/3  4/5 1/5 3/4  5/7  
1f 3 1 2 f y 3/3 4/4 2/4   2/3  3/4 5/5 3/8  3/7  
1f 4 1 2 f y 3/4 2/4 4/6   2/3  3/4 5/5 3/8  4/7  
1g 1 x x m n 2/4 4/4 2/6   2/3  1/5 3/6 3/8  3/7  
1g 2 x x f n 4/5 2/4 1/5   1/3  3/6 1/5 7/8  2/5  
1g 3 1 2 f y 4/5 2/4 5/6   1/3  1/3 3/5 3/8  2/3  
1g 4 1 2 f y 2/4 4/4 1/2   2/3  5/6 1/6 7/8  2/3  
1h 1 x x m n 3/5 4/4 3/3   2/3  2/6 5/6 8/8  3/6  
1h 2 x x f n 2/5 4/5 3/3   3/4  2/3 1/5 1/3  3/3  
1h 3 1 2 f y 2/5 4/4 3/3   2/3  2/6 1/5 1/8  x/x  
1h 4 1 2 f y 3/5 4/5 3/3   3/4  2/3 1/6 3/8  x/x  
1i 1 x x m n 4/4 4/4 3/6   2/3  4/5 5/6 7/8  2/4  
1i 2 x x f n 2/3 4/6 4/6   1/2  1/5 5/6 7/8  3/3  
1i 3 1 2 f y 3/4 4/6 4/6   1/2  1/5 5/5 7/8  3/4  
1i 4 1 2 f y 3/4 4/6 4/6   1/2  1/5 5/5 7/8  3/4  
#--- Page 2 a-i ----
2a 1 x x m n 2/5 4/7 2/6   1/3  3/4 4/5 2/4  3/4  
2a 2 x x f n 5/5 4/4 4/7   3/5  4/5 3/6 3/4  2/5  
2a 3 1 2 m y 2/5 4/7 4/6   3/3  4/4 3/4 3/4  3/5  
2a 4 1 2 m y 2/5 4/7 6/7   3/5  4/5 3/4 4/4  4/5  
2a 5 1 2 f y 5/5 4/4 2/4   1/3  3/4 5/6 2/3  2/3  
2b 1 x x m n 3/4 4/7 4/6   1/3  3/4 5/8 1/8  x/x  
2b 2 x x f n x/x 1/4 4/6   3/6  4/5 3/5 3/12 x/x  
2b 3 1 2 f y 3/4 4/7 4/6   3/3  4/4 3/5 3/8  4/7  
2b 4 1 2 m y 3/4 4/7 4/6   3/3  4/4 5/5 3/8  4/4  
2c 1 x x m n 2/4 2/4 4/5   3/7  2/3 1/5 7/8  3/5  
2c 2 x x f n 3/5 3/4 2/4   1/3  3/5 5/5 3/7  3/3  
2c 3 1 2 f y 4/5 4/4 2/5   3/3  3/3 1/5 3/7  3/3  
2c 4 1 2 f y 4/5 4/4 2/5   3/3  3/3 1/5 3/7  3/3  
2d 1 x x m n 4/5 4/5 5/6   1/6  4/5 1/1 4/10 5/5  
2d 2 x x f n x/x 4/9 x/x   x/x  2/5 5/6 1/3  3/4  
2d 3 1 2 m y 4/4 4/9 4/5   1/3  2/5 1/6 1/10 4/5  
2d 4 1 2 m y 4/4 4/9 4/5   1/3  2/5 1/6 1/10 3/5  
2e 1 x x m n 4/5 4/5 3/3   3/7  2/3 3/6 3/8  3/4  
2e 2 x x f n 5/5 5/5 3/6   3/6  3/5 4/5 4/6  2/2  
2e 3 1 2 f y 4/5 x/x 3/6   3/6  2/3 3/5 6/8  2/3  
2e 4 1 2 f y 5/5 4/5 3/6   6/7  3/3 5/6 3/6  2/4  
2f 1 x x m n x/x x/x x/x   x/x  x/x 4/6 x/x  4/5  
2f 2 x x f n 4/5 2/5 10/10 1/5  3/5 1/5 1/8  5/6  
2f 3 1 2 m y 4/6 2/4 6/10  1/6  2/3 4/5 1/3  5/6  
2f 4 1 2 f y 5/6 4/5 6/10  5/6  3/5 1/6 3/8  4/6  
2g 1 x x m n 5/6 4/4 3/6   1/3  4/5 2/5 8/9  3/6  
2g 2 x x f n 5/6 3/4 3/4   2/3  3/4 5/7 7/8  4/6  
2g 3 1 2 m y 5/5 4/4 4/6   2/3  3/4 5/7 7/8  3/6  
2g 4 1 2 m y 5/5 4/4 4/6   2/3  3/4 5/7 7/8  3/6  
2h 1 x x m n x/x 4/7 x/x   x/x  x/x 1/6 x/x  1/2  
2h 2 x x f n 4/6 4/6 2/5   3/6  1/7 1/4 3/7  3/5  
2h 3 1 2 m y 5/6 4/4 2/5   1/6  4/7 4/6 3/4  2/3  
2h 4 1 2 f y 5/6 4/4 2/5   1/6  4/7 4/6 3/4  2/3  
2h 5 1 2 m y 5/6 4/7 2/5   1/6  1/7 1/4 3/4  1/3  
2i 1 x x m n 4/8 2/4 2/5   2/3  3/5 4/6 4/8  2/3  
2i 2 x x f n 4/5 3/4 4/5   6/7  2/5 4/5 8/9  3/4  
2i 3 1 2 f y 4/8 3/4 2/5   3/6  2/3 4/6 4/9  3/4  
2i 4 1 2 f y 5/8 4/4 4/5   3/7  2/3 4/4 8/9  3/4  
#--- Page 3 a-i ----
3a 1 x x m n x/x 4/5 5/7   1/3  3/7 x/x 7/8  1/5  
3a 2 x x f n 4/5 2/5 3/4   6/7  5/7 4/4 3/8  4/6  
3a 3 1 2 f y 4/4 2/4 4/7   3/7  3/5 1/4 7/8  1/6  
3a 4 1 2 m y 4/5 2/4 4/7   3/7  3/7 1/4 7/8  4/5  
3b 1 x x m n x/x x/x x/x   x/x  x/x x/x x/x  x/x  
3b 2 x x f n x/x x/x x/x   x/x  x/x x/x x/x  x/x  
3b 6 x x f n 4/5 2/4 4/7   3/5  4/5 4/7 3/4  3/4  
3b 3 1 2 m n 5/5 4/7 4/6   1/3  4/5 1/4 3/3  3/4  
3b 4 1 2 m y 5/5 2/4 4/5   2/7  3/5 2/5 3/4  3/4  
3b 5 1 2 m y 5/5 4/7 4/5   2/7  3/5 2/5 3/4  3/4  
3b 7 5 6 m y 5/5 4/4 5/7   2/3  5/5 4/5 3/4  3/4  
3b 8 5 6 f y 5/5 2/4 5/7   2/3  5/5 4/5 3/4  3/4  
3c 1 x x m n 2/4 2/4 4/5   3/7  4/5 1/2 3/9  4/4  
3c 2 x x f n 4/5 4/5 1/4   2/3  1/6 2/3 1/9  3/7  
3c 3 1 2 f y 4/4 4/4 4/5   2/3  5/6 2/2 1/9  3/4  
3c 4 1 2 f y 4/4 4/4 4/5   2/3  5/6 1/2 1/3  3/4  
3d 1 x x m n x/x x/x 4/6   x/x  x/x 1/3 1/7  3/4  
3d 2 x x f n 2/5 4/5 3/4   3/3  3/5 4/6 7/8  4/4  
3d 3 1 2 f y 4/5 4/5 4/6   3/3  3/3 3/6 1/8  4/4  
3d 4 1 2 m y 4/5 5/5 4/4   3/3  3/3 1/6 7/8  3/4  
3d 5 1 2 f y 4/5 5/5 4/4   3/3  3/3 1/6 7/8  3/4  
3e 1 x x m n 2/6 4/4 5/5   1/3  2/5 1/6 1/11 5/10 
3e 2 x x f n 4/5 2/4 3/4   3/6  3/5 1/5 3/3  1/1  
3e 3 1 2 f y 2/4 4/4 4/5   1/6  5/5 1/1 1/3  1/5  
3e 4 1 2 f y x/x 2/4 4/5   1/6  5/5 1/1 1/3  1/5  
3f 1 x x m n x/x 4/6 5/6   2/6  2/4 5/7 3/4  x/x  
3f 2 x x f y 3/4 2/4 5/6   2/4  3/5 5/6 7/13 2/4  
3f 3 1 2 m y 4/5 4/4 6/6   4/6  4/5 5/6 4/7  2/4  
3f 4 1 2 m y 3/4 2/4 5/5   2/2  2/3 5/7 3/13 3/4  
3g 1 x x m n 4/5 4/7 6/6   3/3  1/2 3/6 3/7  4/4  
3g 2 x x f n 3/3 4/5 4/6   1/3  2/3 1/4 3/5  3/4  
3g 3 1 2 m y 3/5 4/4 4/6   1/3  1/3 3/4 3/5  3/4  
3g 4 1 2 m y 3/5 4/5 4/6   1/3  1/2 1/3 3/3  4/4  
3h 1 x x m n 4/4 2/4 3/4   1/3  3/5 1/5 4/8  4/7  
3h 2 x x f n 5/6 x/x 1/9   1/2  3/6 1/6 x/x  4/5  
3h 3 1 2 m y 4/6 2/7 3/9   1/3  3/3 1/1 3/8  4/4  
3h 4 1 2 m y 4/5 2/4 1/3   2/3  3/6 1/6 3/8  4/5  
3i 1 x x m n 3/5 4/7 5/6   1/3  4/5 1/1 x/x  4/5  
3i 2 x x f n 5/6 4/7 2/3   1/3  4/4 4/5 x/x  3/5  
3i 3 1 2 f y 5/6 4/7 2/6   1/3  4/4 1/4 x/x  4/5  
3i 4 1 2 f y 5/6 4/4 2/5   1/1  x/x 1/5 x/x  3/4  
#--- Page 4 a-i ----
4a 1 x x m n 4/4 4/4 3/6   3/6  3/4 5/5 3/8  3/5  
4a 2 x x f n 5/5 2/4 5/6   2/3  2/4 1/5 3/4  4/5  
4a 3 1 2 m y 4/5 4/4 5/6   2/6  2/4 1/5 3/4  3/4  
4a 4 1 2 f y 4/5 4/4 5/6   2/6  2/4 5/5 3/8  5/5  
4b 1 x x m n 5/6 4/7 4/5   1/3  3/5 x/x 1/3  1/2  
4b 2 x x f n 4/4 1/7 6/6   3/3  3/3 3/5 8/9  2/3  
4b 3 1 2 f y 4/6 7/7 4/6   3/3  3/5 3/5 1/9  2/3  
4b 4 1 2 f y 4/5 1/4 5/6   1/3  3/3 1/3 3/9  2/2  
4c 1 x x m n 4/5 4/7 2/7   3/7  2/3 3/6 2/3  3/4  
4c 2 x x f n 3/5 2/7 5/5   1/3  5/6 6/7 3/8  3/5  
4c 3 1 2 f y 3/4 4/7 2/5   1/3  2/6 6/6 2/3  3/4  
4c 4 1 2 f y 3/5 7/7 5/7   3/3  3/5 3/7 3/8  3/4  
4c 5 1 2 f y 3/5 7/7 5/7   3/3  3/5 3/6 2/3  3/4  
4d 1 x x m n 4/5 4/4 2/4   1/6  1/3 4/8 x/x  3/4  
4d 2 x x f n 4/5 2/5 4/4   3/6  3/5 4/7 3/4  3/5  
4d 3 1 2 m y 4/5 2/4 4/4   3/6  1/3 4/8 4/8  3/3  
4d 4 1 2 f y 5/5 4/5 4/4   3/6  1/3 7/8 3/8  3/5  
4d 5 1 2 m y 4/5 2/4 4/4   3/6  3/3 4/4 4/8  3/4  
4e 1 x x m n x/x x/x 3/6   6/7  2/5 5/7 x/x  3/4  
4e 2 x x f n 5/6 5/7 4/4   7/9  4/7 5/6 3/4  4/6  
4e 3 1 2 m y 5/6 4/5 4/6   7/9  4/5 5/7 3/8  4/4  
4e 4 1 2 m y 4/6 4/7 4/6   7/7  2/4 6/7 3/8  4/6  
4f 1 x x m n 5/6 2/4 4/6   3/3  2/4 6/6 4/4  3/5  
4f 2 x x f n 4/4 4/4 3/4   5/6  4/5 1/1 6/15 4/6  
4f 3 1 2 m y 4/5 2/4 3/4   3/6  4/4 1/6 4/15 3/4  
4f 4 1 2 m y 4/5 2/4 4/4   3/5  4/5 1/6 4/6  4/5  
4g 1 x x m n x/x 4/7 3/7   3/6  x/x 1/5 4/8  5/6  
4g 2 x x f n 5/5 4/5 2/4   3/3  4/5 1/7 3/8  3/4  
4g 3 1 2 m y 5/5 5/7 2/3   3/6  4/6 1/1 3/8  4/5  
4g 4 1 2 f y 5/5 4/4 3/4   3/3  5/6 1/1 3/8  4/5  
4h 1 x x m n 4/5 4/7 4/6   2/3  2/3 3/4 3/9  3/5  
4h 2 x x f n 4/6 2/4 5/5   3/3  2/3 3/5 7/8  3/6  
4h 3 1 2 f y 4/6 2/7 5/6   2/3  2/3 3/5 3/8  3/6  
4h 4 1 2 m y 4/6 2/4 4/5   3/3  2/2 4/5 8/9  3/5  
4i 1 x x m n x/x x/x 3/7   x/x  x/x x/x x/x  5/6  
4i 2 x x f n 4/5 4/7 3/6   3/3  3/4 5/6 3/8  4/4  
4i 3 1 2 f y 4/6 4/5 3/3   3/3  2/4 5/6 3/8  4/6  
4i 4 1 2 m y 4/6 4/5 3/3   3/3  2/4 5/6 3/8  4/5  
4i 5 1 2 m y 4/6 4/5 3/7   3/3  2/4 6/6 3/8  4/6  
#--- Page 5 a-i ----
5a 1 x x m n 4/5 4/7 4/6   3/10 4/5 5/6 1/8  2/5  
5a 2 x x f n 3/4 2/7 2/5   3/7  3/4 5/8 3/3  4/5  
5a 3 1 2 f y 3/4 2/4 2/6   3/3  3/5 6/8 3/8  2/4  
5a 4 1 2 m y 4/4 4/7 5/6   3/7  4/5 5/6 3/8  2/5  
5b 1 x x m n 4/6 x/x 4/6   x/x  x/x x/x 8/9  3/4  
5b 2 x x f n 3/4 4/4 3/6   1/7  4/4 6/7 3/8  5/7  
5b 3 1 2 f y 4/4 4/4 3/4   1/3  3/4 5/6 8/8  4/7  
5b 4 1 2 f y 4/4 4/4 3/6   1/3  3/4 5/6 8/8  4/7  
5c 1 x x m n 5/5 4/4 1/3   2/3  1/5 5/6 3/8  4/4  
5c 2 x x f n 4/6 4/7 2/4   3/3  2/5 5/5 7/8  6/6  
5c 3 1 2 m y 4/5 4/7 3/4   2/3  1/5 5/5 3/8  4/6  
5c 4 1 2 m y 4/5 4/7 3/4   2/3  1/5 5/5 3/8  4/6  
5d 1 x x m n x/x x/x x/x   x/x  x/x 4/6 x/x  x/x  
5d 2 x x f n 4/5 2/4 4/5   2/3  3/4 4/6 x/x  4/4  
5d 3 1 2 f y 5/5 2/4 3/4   3/3  3/3 4/6 3/4  4/4  
5d 4 1 2 f y 5/5 2/4 3/4   3/3  3/3 6/6 1/4  4/4  
5e 1 x x m n 4/5 2/7 2/7   3/3  3/5 1/5 7/9  4/6  
5e 2 x x f n 4/6 2/4 3/4   x/x  3/5 4/5 8/8  4/4  
5e 3 1 2 m y 4/5 4/7 2/4   3/3  3/3 1/4 8/9  4/6  
5e 4 1 2 f y 4/5 4/7 2/4   3/3  3/3 1/4 8/9  4/6  
5f 1 x x m n 4/5 2/4 4/6   1/3  4/6 1/6 3/4  3/5  
5f 2 x x f n x/x 2/6 1/5   1/6  3/7 1/2 7/8  3/5  
5f 3 1 2 f y 4/4 2/2 4/5   3/6  6/7 1/2 3/8  3/5  
5f 4 1 2 m y 4/4 2/2 5/6   1/6  3/4 1/6 4/7  3/5  
5g 1 x x m n 3/5 4/4 4/6   3/7  2/6 3/5 3/15 2/3  
5g 2 x x f n 3/6 4/4 3/4   3/3  3/6 1/3 8/9  2/3  
5g 3 1 2 f y 3/3 4/4 4/4   3/3  3/6 1/5 3/8  2/3  
5g 4 1 2 f y 5/6 4/4 4/4   3/7  2/3 1/3 3/8  3/3  
5h 1 x x m n 3/5 4/4 4/6   3/7  2/6 3/5 3/15 2/3  
5h 2 x x f n 3/6 4/4 3/4   3/3  3/6 1/3 8/9  2/3  
5h 3 1 2 f y 3/3 4/4 4/4   3/3  3/6 1/5 3/8  2/3  
5h 4 1 2 f y 5/6 4/4 4/4   3/7  2/3 1/3 3/8  3/3  
5i 1 x x m n 2/2 4/5 2/4   2/3  3/5 5/6 7/8  3/5  
5i 2 x x f n 3/5 4/5 4/6   2/3  3/3 2/5 7/9  3/4  
5i 3 1 2 f y 2/5 5/5 4/6   2/3  3/3 5/5 7/8  3/4  
5i 4 1 2 f y 2/3 4/4 4/6   2/3  3/5 2/5 8/9  3/3  
#--- Page 6 a-i ----
6a 1 x x m n 4/5 4/6 4/5   1/3  1/2 4/4 4/8  2/5  
6a 2 x x f n 1/5 4/6 1/2   2/3  1/2 4/4 4/8  3/5  
6a 3 1 2 f y x/x 4/6 2/5   1/3  1/2 4/4 8/8  5/5  
6a 4 1 2 f y 4/5 4/4 1/5   1/3  1/2 4/4 8/8  5/5  
6b 1 x x m n x/x x/x x/x   x/x  x/x 5/6 x/x  x/x  
6b 2 x x f n 3/4 4/7 4/5   1/3  4/6 2/5 4/9  3/6  
6b 3 1 2 f y 3/5 4/7 4/5   1/2  2/4 5/5 8/9  3/6  
6b 4 1 2 f y 3/5 4/7 4/5   1/2  2/4 5/6 8/9  3/6  
6c 1 x x m n 2/5 4/4 6/6   3/6  2/4 5/5 8/8  4/4  
6c 2 x x f n 3/5 4/5 3/4   3/7  4/5 x/x 3/8  x/x  
6c 3 1 2 f y 5/5 4/4 4/6   6/7  4/4 1/5 3/8  3/4  
6c 4 1 2 f y 3/5 4/5 4/6   3/6  4/4 1/5 8/8  3/4  
6d 1 x x m n 2/6 4/5 6/7   3/5  3/5 4/5 5/8  3/4  
6d 2 x x f n 3/5 4/6 3/7   2/2  3/5 4/4 3/8  1/5  
6d 3 1 2 f y 5/6 4/6 3/6   2/3  5/5 4/4 5/8  1/4  
6d 4 1 2 f y 3/6 4/4 6/7   2/3  5/5 4/4 5/8  1/4  
6e 1 x x m n 3/5 1/2 3/6   1/1  6/8 x/x 3/8  2/4  
6e 2 x x f y 3/5 2/2 3/3   1/3  2/6 x/x 8/8  4/4  
6e 3 1 2 m y x/x 2/2 3/3   1/1  2/6 5/6 x/x  2/4  
6e 4 1 2 m y 5/5 2/2 3/6   1/1  2/6 6/7 3/8  2/4  
6f 1 x x m n x/x x/x x/x   x/x  x/x 4/6 3/8  3/5  
6f 2 x x f n 3/3 1/4 6/6   3/3  2/6 1/4 3/7  4/4  
6f 3 1 2 f y 3/3 4/4 6/6   3/3  2/5 4/4 3/8  4/5  
6f 4 1 2 f y x/x 1/4 6/6   3/3  5/6 1/6 3/3  4/5  
6g 1 x x m n x/x x/x x/x   x/x  x/x x/x x/x  x/x  
6g 2 x x f n x/x 5/8 4/6   x/x  4/7 1/2 x/x  x/x  
6g 3 1 2 f y x/x 5/7 3/6   1/1  4/7 1/8 1/1  1/1  
6g 4 1 2 f y x/x 7/8 3/6   1/1  4/7 1/8 1/1  1/1  
6h 1 x x m y 5/5 4/4 2/6   3/3  7/7 1/5 3/7  2/5  
6h 2 x x f n 2/3 2/5 4/6   3/6  7/7 1/5 3/8  4/5  
6h 3 1 2 f y 3/5 2/4 6/6   3/3  7/7 1/5 7/8  2/5  
6h 4 1 2 f y 2/5 4/5 2/4   3/6  7/7 5/5 3/7  4/5  
6h 5 1 2 m y 2/5 4/5 4/6   3/6  7/7 5/5 3/7  2/4  
6i 1 x x m n x/x x/x x/x   x/x  x/x x/x x/x  x/x  
6i 2 x x f n x/x x/x x/x   x/x  x/x x/x x/x  x/x  
6i 3 x x m n 4/5 4/7 5/5   6/6  3/3 1/6 2/3  4/5  
6i 4 1 2 f y 3/4 4/4 4/5   3/3  3/3 5/6 4/8  4/5  
6i 5 1 2 f y 3/4 4/4 4/4   3/3  3/3 5/6 4/7  4/5  
6i 6 3 4 f y 3/5 4/4 4/5   3/6  3/3 6/6 2/4  4/5  
6i 7 3 4 f y 4/5 4/4 4/5   3/6  3/3 6/6 2/4  4/4  
;;;;
run
echo
echo ========
echo Test 79
echo ========
echo
describe ibd
echo
echo ========
echo Test 80
echo ========
echo
show loci
echo
echo ========
echo Test 81
echo ========
echo
drop where hwe
undrop
echo
echo
echo ========
echo Test 82
echo ========
echo
keep where hwe < 0.01
undrop
echo
echo ========
echo Test 83
echo ========
echo
drop whe num >= 92
undrop
echo
echo ========
echo Test 84
echo ========
echo
drop whe num 0.4
undrop
echo
echo ========
echo Test 85
echo ========
echo
drop whe num >= 92
undrop
echo
echo ========
echo Test 86
echo ========
echo
keep where position 54 63
undrop
echo
echo ========
echo Test 87
echo ========
echo
describe snp
echo
echo ========
echo Test 88
echo ========
echo
linkage
echo
echo ========
echo Test 89
echo ========
echo
show map
echo
echo ========
echo Test 90
echo ========
echo
show ids 
echo
echo ========
echo Test 91
echo ========
echo
set iterations 50
echo
echo ========
echo Test 92
echo ========
echo
apm ibd
echo
echo ========
echo Test 93
echo ========
echo
apm ibd ibd
echo
echo ========
echo Test 94
echo ========
echo
tdt ibd
clear
echo
echo Family 26 from hypercholesterolemia study of Williams et al JAMA 1986
echo used to establish linkage to LDL-R RFLP in Leppert et al 
echo Am J Hum Genet 1986\; 39: 300-6 and reanalysed by several authors
echo eg Guo & Thompson AJHG 1992; 51:1111-26
echo
set seeds 4576 123 2354 
set locus age qua
set locus CHD aff
set locus carrier aff
set locus adjChol qua
set locus ldl mar
read pedigree inline
26 101   x   x m 62 y y   x x x
26 102   x   x f 91 y n   x x x
26 201 101 102 m 47 y y   x x x
26 202   x   x f  x n n   x x x
26 203 101 102 f 71 n y 227 2 2
26 204   x   x m  x x n   x x x
26 301 201 202 f  x x n   x x x
26 302 201 202 m 38 y y   x x x
26 303   x   x f 53 n n  92 2 2
26 304 201 202 m  x x y 243 1 2
26 305   x   x f  x x n  93 1 1
26 306 201 202 m  x x y 239 1 2
26 307 201 202 m 46 y y 207 1 2
26 308   x   x f 42 n n 145 1 1
26 309 201 202 f  x x n  21 1 1
26 310 201 202 m  x x y   x x x
26 311   x   x f 47 n n  98 1 2
26 312 201 202 m  x y y   x x x
26 313   x   x f  x x n 115 1 1
26 314 201 202 m  x x n  92 1 1
26 315   x   x f  x x n   x x x
26 316 204 203 m 45 y y   x x x
26 317 204 203 m 32 y y   x x x
26 318   x   x f 47 n n 134 1 1
26 319 204 203 f  x x n 104 1 2
26 320 204 203 f  x x n  99 1 2
26 401 302 303 f 31 n n 168 1 2
26 402 302 303 f 29 n y 301 2 2
26 403   x   x m  x x n  69 1 1
26 404 302 303 f 27 n n 154 1 2
26 405   x   x m  x x n 143 1 1
26 406 304 305 f 20 n n  68 1 1
26 407 304 305 m 18 n n  56 1 1
26 408 304 305 f 16 n y 316 1 2
26 409 307 308 m 22 n n 194 1 1
26 410 307 308 f 21 n y 417 1 2
26 411 307 308 m 19 n n 205 1 1
26 412 307 308 m 18 n y 284 1 2
26 413 307 308 f 17 n n 115 1 1
26 414 307 308 f 12 n n 210 1 1
26 415 310 311 f 19 n n 105 1 1
26 416 310 311 f 16 n n 126 1 1
26 417   x   x m  x x n 112 1 1
26 418 312 313 f 15 n y 372 1 2
26 419 312 313 f 14 n n 101 1 1
26 420 312 313 m 13 n y 349 1 2
26 421 312 313 m  6 n y 253 1 2
26 422 316 315 f 24 n y 479 1 2
26 423 317 318 f 22 n n 140 1 1
26 424   x   x m  x x n   x x x
26 425 317 318 f 29 n y 553 1 2
26 426   x   x m  x x n   x x x
26 501 403 402 m  x x y 375 1 2
26 502 403 402 m  x x n 147 1 2
26 503 403 402 f  x x y 299 1 2
26 504 405 404 m  x x n  57 1 1
26 505 405 404 m  x x n  82 1 1
26 506 417 418 f  x x n 125 1 1
26 507 424 425 f  x x n 136 1 1
26 508 426 425 m  x x n 183 1 1
;;;;
run
echo
echo ========
echo Test 95
echo ========
echo
typ
echo
echo ========
echo Test 96
echo ========
echo
typ CHD
echo
echo ========
echo Test 97
echo ========
echo
tab
echo
echo ========
echo Test 98
echo ========
echo
tab CHD carrier
echo
echo ========
echo Test 99
echo ========
echo
tab CHD ldl
set loc logChol qua
echo
echo ========
echo Test 100
echo ========
echo
logChol = log(adjChol)
echo
echo ========
echo Test 101
echo ========
echo
echo =================================================================
echo SAGE (6.0.1) FCOR gives:
echo                Count  Correlation  EqvCnt  StdError  P-values
echo
echo -----------------------------------------------------------------
echo Marital            5  -0.8588561      5.6  0.237164  0.037602 *  
echo Grandparental     11   0.4845441     19.6 [0.185177] 0.031421 *  
echo Avuncular        107  -0.0679835     50.6 [0.141430] 0.638674    
echo Cousin           143  -0.0399115     90.1  0.105774  0.707001    
echo Par-Off           45  -0.0551662     54.8 [0.135952] 0.691061    
echo Sibling           44   0.0338719     28.0  0.192224  0.861506    
echo
echo =================================================================
echo
describe logChol
echo
echo
echo ========
echo Test 102
echo ========
echo
regress logChol on age CHD ldl
echo
echo ========
echo Test 103
echo ========
echo
mix logChol 2 poo  

set iter 50
echo
echo ========
echo Test 104
echo ========
echo
sibpair logChol
echo
echo ========
echo Test 105
echo ========
echo
assoc logChol
echo
echo ========
echo Test 106
echo ========
echo
mgt logChol
echo
echo ========
echo Test 107
echo ========
echo
apm adjChol over 5 ibd
echo
echo ========
echo Test 108
echo ========
echo
apm adjChol over 5
echo
echo ========
echo Test 109
echo ========
echo
tdt adjChol over 5 
echo
echo ========
echo Test 110
echo ========
echo
tdt logChol
echo
echo ========
echo Test 111
echo ========
echo
ass adjChol over 5
echo
echo ========
echo Test 112
echo ========
echo
echo 
echo SUPERLINK 1.6 gives:
echo  Theta   lod
echo  0.0001  8.561008
echo  0.01    8.422634
echo  0.025   8.210869
echo  0.05    7.850694
echo  0.075   7.485948
echo  0.1     7.111979
echo  0.2     5.530992
echo  0.3     3.790529
echo  0.4     1.865282
echo
set loc trait marker
if (carrier) then trait="1/2"
if (not carrier) then trait="1/1"
lod trait ldl
clear
echo
echo Finnish families containing probands suffering from neuronal ceroid
echo lipofuscinosis described in Savukoski et al AJHG 1994\; 55: 695-701.
echo Linkage disequilibrium mapping using 3 chromosome 13 loci
echo
echo D13S162 D13S160 D13S170
echo
echo 13q22-31 D13S162 -- 3cM -- D13S160 -- 3 cM -- D13S170 13q31-32
echo
echo Numbering of individuals runs as per Figure 1 generation by generation
echo and left to right
echo
set seeds 4576 123 2354 
set locus lincl aff
set locus oneperfam aff
set locus D13S162 nam
set locus D13S160 nam
set locus D13S170 nam
read pedigree inline
1  1  x x m n n 2 4 1 5 5  9  
1  2  x x f n n 4 5 3 5 5  7  
1  3  1 2 f y y 4 4 5 5 5  5  
1  4  1 2 m y n 4 4 5 5 5  5  
1  5  1 2 f n n 4 5 3 5 5  7  
1  6  1 2 f n n 2 4 1 3 7  9  
1  7  1 2 f n n 2 4 1 3 7  9  
2  1  x x m n n 4 8 2 5 3  5  
2  2  x x f n n 4 6 4 5 1  5  
2  3  1 2 m n n 6 8 2 4 1  3  
2  4  1 2 m n n 4 6 4 5 5  5  
2  5  1 2 f n n 6 8 2 4 1  3  
2  6  1 2 m n n 4 8 2 5 3  5  
2  7  1 2 m y y 4 4 5 5 5  5  
2  8  1 2 m y n 4 4 5 5 5  5  
2  9  1 2 f n n 4 8 2 5 3  5  
3  1  x x m n n x x x x x  x  
3  2  x x f n n x x x x x  x  
3  3  x x f n n 4 7 4 5 5  8  
3  4  1 2 m n n 4 7 4 5 5  6  
3  5  1 2 m n n 4 7 4 5 5  8  
3  6  x x f n n 3 4 4 5 5  7  
3  7  4 3 f n n 4 7 4 4 6  8  
3  8  4 3 f n n 4 7 4 4 6  8  
3  9  4 3 m y y 4 4 4 5 5  6  
3  10 5 6 m n n 4 7 4 5 5  8  
3  11 5 6 m y n 4 4 5 5 5  5  
4  1  x x m n n 4 8 3 5 5  8  
4  2  x x f n n 1 4 1 5 2  4  
4  3  1 2 m y y 4 4 5 5 2  5  
4  4  1 2 m n n 4 8 3 5 2  8  
5  1  x x m n n 4 5 1 5 6  10 
5  2  x x f n n 4 5 1 6 4  10 
5  3  1 2 f n n 4 4 1 1 10 10 
5  4  1 2 m n n 4 5 5 6 4  6  
5  5  1 2 f n n 4 4 1 5 6  10 
6  1  x x m n n 4 5 1 4 3  11 
6  2  x x f n n 4 4 2 5 3  10 
6  3  1 2 m y y 4 4 1 5 3  3  
6  4  1 2 m n n 4 4 1 2 3  10 
7  1  x x m n n 3 4 5 6 3  7  
7  2  x x f n n 4 6 2 5 4  7  
7  3  1 2 f n n 4 4 5 5 7  7  
7  4  1 2 f n n 4 6 2 5 4  7  
8  1  x x m n n x x x x x  x  
8  2  x x f n n 2 4 3 5 2  5  
8  3  1 2 f n n 2 4 3 5 2  5  
8  4  1 2 f y y 4 4 5 5 5  5  
8  5  1 2 m n n 1 4 1 5 5  8  
9  1  x x m n n 1 4 1 5 2  5  
9  2  x x f n n 4 7 2 5 5  5  
9  3  1 2 m n n 1 7 1 5 5  5  
9  4  1 2 f y y 4 7 5 5 2  5  
10 1  x x m n n 2 5 4 5 5  7  
10 2  x x f n n 4 7 2 5 5  7  
10 3  1 2 f n n 4 5 4 5 5  7  
10 4  1 2 f y y 2 4 5 5 5  5  
11 1  x x m n n 4 4 1 5 3  4  
11 2  x x f n n 2 4 5 6 4  4  
11 3  1 2 m y y 4 4 5 5 4  4  
11 4  1 2 f n n 2 4 5 6 4  4  
12 1  x x m n n 4 4 4 5 x  x  
12 2  x x f n n 3 4 1 2 x  x  
12 3  1 2 f y y 4 4 1 5 x  x  
13 1  x x m n n 4 4 3 5 x  x  
13 2  x x f n n 4 8 2 5 x  x  
13 3  1 2 m y y 4 4 5 5 x  x  
13 4  1 2 f y n 4 4 5 5 x  x  
14 1  x x m n n x x x x x  x  
14 2  x x f n n x x x x x  x  
14 3  1 2 f y y 4 4 5 5 x  x  
14 4  1 2 f n n x x x x x  x  
;;;;
run
echo
echo ========
echo Test 113
echo ========
echo
show pedigrees list
echo
echo ========
echo Test 114
echo ========
echo
show pedigrees
echo
echo ========
echo Test 115
echo ========
echo
fre snp
echo
echo ========
echo Test 116
echo ========
echo
table allelic lincl D13S162
echo
echo ========
echo Test 117
echo ========
echo
set nhap 10
dis
set iter 50
echo
echo ========
echo Test 118
echo ========
echo
hom lincl
echo
echo ========
echo Test 119
echo ========
echo
mul lincl
echo
echo ========
echo Test 120
echo ========
echo
ass lincl
echo
echo ========
echo Test 121
echo ========
echo
mqls lincl prev 0.0001
echo
echo ========
echo Test 122
echo ========
echo
tdt lincl
echo
echo ========
echo Test 123
echo ========
echo
tdt oneperfam
clear
echo
echo Testing QTDT
echo
set seeds 12234 2323 13143
set loc trait  quantitative
set loc marker marker
#
# One hundred triad families
#
simulate pedigrees 100 2 1 1
run
sim marker 0.6 0.4
if (marker=="1/1") then trait=rnorm else trait=rnorm+0.75
if (isfou) then trait=x
echo
echo ========
echo Test 124
echo ========
echo MENDEL Gametic competition model P=0.0155
echo QTDT Orthogonal model F=4.84     P=0.0301
echo
tdt trait
clear
echo
echo Testing conditional logistic regression:
echo
#
# Matched case-control study data from
# Trichopoulos et al. (1976) Br J Obs Gynaec 83: 645-650.
# 
#             coef exp(coef) se(coef)    z       p
# spontaneous 1.99      7.29    0.352 5.63 1.8e-08
# induced     1.41      4.09    0.361 3.91 9.4e-05
# 
# Likelihood ratio test=53.1  on 2 df, p=2.87e-12  n= 248 
# 
set locus education    cat . 1 = 0-5 2= 6-11 3= 12+
set locus age          qua . age in years
set locus parity       qua . count
set locus induced      qua . TOP 0=0 1=1 2=2+
set locus case         qua . 
set locus spontaneous  qua . miscarriage 0=0 1=1 2=2+
set locus stratum      cat . matching stratum
read pedigree inline
#
# strat id      education age parity induced case spontaneous stratum
1       1    f1 m2 f 1      26  6      1       1    2           1   
1       84   f1 m2 f 1      26  6      2       0    0           1   
1       166  f1 m2 f 1      26  6      2       0    0           1   
2       2    f1 m2 f 1      42  1      1       1    0           2   
2       85   f1 m2 f 1      42  1      0       0    0           2   
2       167  f1 m2 f 1      42  1      0       0    0           2   
3       3    f1 m2 f 1      39  6      2       1    0           3   
3       86   f1 m2 f 1      39  6      2       0    0           3   
3       168  f1 m2 f 1      39  6      2       0    0           3   
4       4    f1 m2 f 1      34  4      2       1    0           4   
4       87   f1 m2 f 1      34  4      0       0    1           4   
4       169  f1 m2 f 1      34  4      0       0    2           4   
5       5    f1 m2 f 2      35  3      1       1    1           5   
5       88   f1 m2 f 2      35  3      2       0    0           5   
5       170  f1 m2 f 2      35  3      0       0    0           5   
6       6    f1 m2 f 2      36  4      2       1    1           6   
6       89   f1 m2 f 2      36  4      1       0    1           6   
6       171  f1 m2 f 2      36  4      0       0    2           6   
7       7    f1 m2 f 2      23  1      0       1    0           7   
7       90   f1 m2 f 2      23  1      0       0    0           7   
7       172  f1 m2 f 2      23  1      0       0    0           7   
8       8    f1 m2 f 2      32  2      0       1    0           8   
8       91   f1 m2 f 2      32  2      2       0    0           8   
8       173  f1 m2 f 2      32  2      0       0    1           8   
9       9    f1 m2 f 2      21  1      0       1    1           9   
9       92   f1 m2 f 2      21  1      0       0    1           9   
9       174  f1 m2 f 2      21  1      1       0    0           9   
10      10   f1 m2 f 2      28  2      0       1    0           10  
10      93   f1 m2 f 2      28  2      0       0    1           10  
10      175  f1 m2 f 2      28  2      0       0    1           10  
11      11   f1 m2 f 2      29  2      1       1    0           11  
11      94   f1 m2 f 2      29  2      0       0    0           11  
11      176  f1 m2 f 2      29  2      0       0    1           11  
12      12   f1 m2 f 2      37  4      2       1    1           12  
12      95   f1 m2 f 2      37  4      1       0    1           12  
12      177  f1 m2 f 2      37  4      0       0    1           12  
13      13   f1 m2 f 2      31  1      1       1    0           13  
13      96   f1 m2 f 2      31  1      0       0    0           13  
13      178  f1 m2 f 2      31  1      0       0    0           13  
14      14   f1 m2 f 2      29  3      2       1    0           14  
14      97   f1 m2 f 2      29  3      0       0    1           14  
14      179  f1 m2 f 2      29  3      0       0    2           14  
15      15   f1 m2 f 2      31  2      1       1    1           15  
15      98   f1 m2 f 2      31  2      1       0    0           15  
15      180  f1 m2 f 2      31  2      1       0    0           15  
16      16   f1 m2 f 2      27  2      2       1    0           16  
16      99   f1 m2 f 2      27  2      1       0    0           16  
16      181  f1 m2 f 2      27  2      0       0    0           16  
17      17   f1 m2 f 2      30  5      2       1    1           17  
17      100  f1 m2 f 2      30  5      0       0    2           17  
17      182  f1 m2 f 2      30  5      1       0    2           17  
18      18   f1 m2 f 2      26  1      0       1    1           18  
18      101  f1 m2 f 2      26  1      0       0    0           18  
18      183  f1 m2 f 2      26  1      1       0    0           18  
19      19   f1 m2 f 2      25  3      2       1    1           19  
19      102  f1 m2 f 2      25  3      0       0    1           19  
19      184  f1 m2 f 2      25  3      1       0    1           19  
20      20   f1 m2 f 2      44  1      0       1    1           20  
20      103  f1 m2 f 2      44  1      0       0    0           20  
20      185  f1 m2 f 2      44  1      1       0    0           20  
21      21   f1 m2 f 2      40  1      0       1    1           21  
21      104  f1 m2 f 2      40  1      0       0    0           21  
21      186  f1 m2 f 2      40  1      0       0    0           21  
22      22   f1 m2 f 2      35  2      2       1    0           22  
22      105  f1 m2 f 2      35  2      0       0    0           22  
22      187  f1 m2 f 2      35  2      0       0    0           22  
23      23   f1 m2 f 2      28  2      0       1    2           23  
23      106  f1 m2 f 2      28  2      0       0    0           23  
23      188  f1 m2 f 2      28  2      2       0    0           23  
24      24   f1 m2 f 2      36  1      0       1    1           24  
24      107  f1 m2 f 2      36  1      0       0    0           24  
24      189  f1 m2 f 2      36  1      0       0    1           24  
25      25   f1 m2 f 2      27  2      1       1    1           25  
25      108  f1 m2 f 2      27  2      0       0    1           25  
25      190  f1 m2 f 2      27  2      0       0    2           25  
26      26   f1 m2 f 2      40  2      0       1    2           26  
26      109  f1 m2 f 2      40  2      0       0    0           26  
26      191  f1 m2 f 2      40  2      0       0    0           26  
27      27   f1 m2 f 2      38  2      0       1    2           27  
27      110  f1 m2 f 2      38  2      0       0    0           27  
27      192  f1 m2 f 2      38  2      0       0    0           27  
28      28   f1 m2 f 2      34  3      0       1    2           28  
28      111  f1 m2 f 2      34  3      0       0    0           28  
28      193  f1 m2 f 2      34  3      0       0    0           28  
29      29   f1 m2 f 2      28  4      1       1    2           29  
29      112  f1 m2 f 2      28  4      0       0    2           29  
29      194  f1 m2 f 2      28  4      2       0    1           29  
30      30   f1 m2 f 2      30  4      2       1    0           30  
30      113  f1 m2 f 2      30  4      1       0    1           30  
30      195  f1 m2 f 2      30  4      1       0    1           30  
31      31   f1 m2 f 2      32  1      0       1    1           31  
31      114  f1 m2 f 2      32  1      0       0    0           31  
31      196  f1 m2 f 2      32  1      0       0    0           31  
32      32   f1 m2 f 2      34  2      1       1    0           32  
32      115  f1 m2 f 2      34  2      1       0    0           32  
32      197  f1 m2 f 2      34  2      0       0    0           32  
33      33   f1 m2 f 2      42  1      1       1    0           33  
33      116  f1 m2 f 2      42  1      1       0    0           33  
33      198  f1 m2 f 2      42  1      0       0    0           33  
34      34   f1 m2 f 2      32  2      0       1    2           34  
34      117  f1 m2 f 2      32  2      0       0    0           34  
34      199  f1 m2 f 2      32  2      2       0    0           34  
35      35   f1 m2 f 2      39  1      1       1    0           35  
35      118  f1 m2 f 2      39  1      0       0    0           35  
35      200  f1 m2 f 2      39  1      0       0    0           35  
36      36   f1 m2 f 2      35  2      0       1    2           36  
36      119  f1 m2 f 2      35  2      0       0    0           36  
36      201  f1 m2 f 2      35  2      0       0    0           36  
37      37   f1 m2 f 2      36  1      0       1    1           37  
37      120  f1 m2 f 2      36  1      0       0    0           37  
37      202  f1 m2 f 2      36  1      0       0    0           37  
38      38   f1 m2 f 2      34  3      1       1    2           38  
38      121  f1 m2 f 2      34  3      2       0    0           38  
38      203  f1 m2 f 2      34  3      2       0    0           38  
39      39   f1 m2 f 2      30  3      0       1    0           39  
39      122  f1 m2 f 2      30  3      0       0    2           39  
39      204  f1 m2 f 2      30  3      0       0    1           39  
40      40   f1 m2 f 2      28  1      0       1    1           40  
40      123  f1 m2 f 2      28  1      1       0    0           40  
40      205  f1 m2 f 2      28  1      0       0    0           40  
41      41   f1 m2 f 2      39  3      0       1    2           41  
41      124  f1 m2 f 2      39  3      1       0    0           41  
41      206  f1 m2 f 2      39  3      0       0    0           41  
42      42   f1 m2 f 2      35  1      0       1    0           42  
42      125  f1 m2 f 2      35  1      0       0    0           42  
42      207  f1 m2 f 2      35  1      0       0    0           42  
43      43   f1 m2 f 2      41  1      0       1    0           43  
43      126  f1 m2 f 2      41  1      0       0    0           43  
43      208  f1 m2 f 2      41  1      0       0    0           43  
44      44   f1 m2 f 2      37  2      1       1    1           44  
44      127  f1 m2 f 2      37  2      0       0    0           44  
44      209  f1 m2 f 2      37  2      0       0    0           44  
45      45   f1 m2 f 3      30  1      0       1    0           45  
45      128  f1 m2 f 3      30  1      1       0    0           45  
45      210  f1 m2 f 3      30  1      0       0    0           45  
46      46   f1 m2 f 3      37  1      1       1    0           46  
46      129  f1 m2 f 3      37  1      0       0    0           46  
46      211  f1 m2 f 3      37  1      0       0    1           46  
47      47   f1 m2 f 3      28  2      0       1    2           47  
47      130  f1 m2 f 3      28  2      1       0    0           47  
47      212  f1 m2 f 3      28  2      1       0    0           47  
48      48   f1 m2 f 3      27  4      2       1    0           48  
48      131  f1 m2 f 3      27  4      2       0    1           48  
48      213  f1 m2 f 3      27  4      2       0    0           48  
49      49   f1 m2 f 3      26  2      2       1    0           49  
49      132  f1 m2 f 3      26  2      1       0    0           49  
49      214  f1 m2 f 3      26  2      1       0    0           49  
50      50   f1 m2 f 3      38  3      0       1    2           50  
50      133  f1 m2 f 3      38  3      1       0    0           50  
50      215  f1 m2 f 3      38  3      1       0    0           50  
51      51   f1 m2 f 3      24  3      1       1    2           51  
51      134  f1 m2 f 3      24  3      2       0    1           51  
51      216  f1 m2 f 3      24  3      2       0    0           51  
52      52   f1 m2 f 3      36  5      1       1    2           52  
52      135  f1 m2 f 3      36  5      1       0    1           52  
52      217  f1 m2 f 3      36  5      2       0    1           52  
53      53   f1 m2 f 3      27  3      1       1    1           53  
53      136  f1 m2 f 3      27  3      1       0    1           53  
53      218  f1 m2 f 3      27  3      2       0    0           53  
54      54   f1 m2 f 3      28  1      0       1    1           54  
54      137  f1 m2 f 3      28  1      1       0    0           54  
54      219  f1 m2 f 3      28  1      0       0    1           54  
55      55   f1 m2 f 3      29  2      0       1    2           55  
55      138  f1 m2 f 3      29  2      1       0    0           55  
55      220  f1 m2 f 3      29  2      1       0    1           55  
56      56   f1 m2 f 3      36  2      0       1    2           56  
56      139  f1 m2 f 3      36  2      1       0    0           56  
56      221  f1 m2 f 3      36  2      0       0    1           56  
57      57   f1 m2 f 3      28  2      1       1    0           57  
57      140  f1 m2 f 3      28  2      1       0    1           57  
57      222  f1 m2 f 3      28  2      2       0    0           57  
58      58   f1 m2 f 3      28  2      0       1    2           58  
58      141  f1 m2 f 3      28  2      2       0    0           58  
58      223  f1 m2 f 3      28  2      1       0    0           58  
59      59   f1 m2 f 3      28  1      0       1    1           59  
59      142  f1 m2 f 3      28  1      1       0    0           59  
59      224  f1 m2 f 3      28  1      0       0    0           59  
60      60   f1 m2 f 3      27  2      0       1    2           60  
60      143  f1 m2 f 3      27  2      1       0    0           60  
60      225  f1 m2 f 3      27  2      1       0    0           60  
61      61   f1 m2 f 3      35  2      0       1    2           61  
61      144  f1 m2 f 3      35  2      2       0    0           61  
61      226  f1 m2 f 3      35  2      1       0    0           61  
62      62   f1 m2 f 3      25  1      0       1    1           62  
62      145  f1 m2 f 3      25  1      1       0    0           62  
62      227  f1 m2 f 3      25  1      1       0    0           62  
63      63   f1 m2 f 3      34  1      0       1    1           63  
63      146  f1 m2 f 3      34  1      0       0    0           63  
63      228  f1 m2 f 3      34  1      0       0    0           63  
64      64   f1 m2 f 3      31  2      0       1    2           64  
64      147  f1 m2 f 3      31  2      0       0    0           64  
64      229  f1 m2 f 3      31  2      1       0    0           64  
65      65   f1 m2 f 3      26  2      1       1    0           65  
65      148  f1 m2 f 3      26  2      0       0    1           65  
65      230  f1 m2 f 3      26  2      0       0    2           65  
66      66   f1 m2 f 3      32  1      0       1    1           66  
66      149  f1 m2 f 3      32  1      0       0    0           66  
66      231  f1 m2 f 3      32  1      1       0    0           66  
67      67   f1 m2 f 3      21  1      0       1    1           67  
67      150  f1 m2 f 3      21  1      0       0    1           67  
67      232  f1 m2 f 3      21  1      0       0    0           67  
68      68   f1 m2 f 3      28  3      1       1    2           68  
68      151  f1 m2 f 3      28  3      2       0    0           68  
68      233  f1 m2 f 3      28  3      2       0    0           68  
69      69   f1 m2 f 3      37  3      0       1    2           69  
69      152  f1 m2 f 3      37  3      1       0    1           69  
69      234  f1 m2 f 3      37  3      0       0    2           69  
70      70   f1 m2 f 3      25  1      1       1    0           70  
70      153  f1 m2 f 3      25  1      0       0    0           70  
70      235  f1 m2 f 3      25  1      1       0    0           70  
71      71   f1 m2 f 3      32  1      1       1    0           71  
71      154  f1 m2 f 3      32  1      1       0    0           71  
71      236  f1 m2 f 3      32  1      0       0    0           71  
72      72   f1 m2 f 3      25  1      0       1    1           72  
72      155  f1 m2 f 3      25  1      0       0    0           72  
72      237  f1 m2 f 3      25  1      1       0    0           72  
73      73   f1 m2 f 3      31  1      0       1    1           73  
73      156  f1 m2 f 3      31  1      0       0    1           73  
73      238  f1 m2 f 3      31  1      0       0    0           73  
74      74   f1 m2 f 3      38  6      0       1    2           74  
74      239  f1 m2 f 3      38  6      0       0    2           74  
75      75   f1 m2 f 3      26  2      0       1    2           75  
75      157  f1 m2 f 3      26  2      0       0    2           75  
75      240  f1 m2 f 3      26  2      1       0    1           75  
76      76   f1 m2 f 3      31  1      0       1    1           76  
76      158  f1 m2 f 3      31  1      0       0    0           76  
76      241  f1 m2 f 3      31  1      1       0    0           76  
77      77   f1 m2 f 3      31  2      0       1    1           77  
77      159  f1 m2 f 3      31  2      2       0    0           77  
77      242  f1 m2 f 3      31  2      0       0    1           77  
78      78   f1 m2 f 3      25  1      1       1    0           78  
78      160  f1 m2 f 3      25  1      0       0    0           78  
78      243  f1 m2 f 3      25  1      0       0    1           78  
79      79   f1 m2 f 3      31  1      0       1    1           79  
79      161  f1 m2 f 3      31  1      0       0    0           79  
79      244  f1 m2 f 3      31  1      0       0    1           79  
80      80   f1 m2 f 3      34  1      0       1    1           80  
80      162  f1 m2 f 3      34  1      0       0    0           80  
80      245  f1 m2 f 3      34  1      0       0    0           80  
81      81   f1 m2 f 3      35  2      2       1    0           81  
81      163  f1 m2 f 3      35  2      0       0    0           81  
81      246  f1 m2 f 3      35  2      2       0    0           81  
82      82   f1 m2 f 3      29  1      0       1    1           82  
82      164  f1 m2 f 3      29  1      0       0    1           82  
82      247  f1 m2 f 3      29  1      0       0    1           82  
83      83   f1 m2 f 3      23  1      0       1    1           83  
83      165  f1 m2 f 3      23  1      0       0    1           83  
83      248  f1 m2 f 3      23  1      0       0    1           83  
;;;;
run
recast case affection
head
echo
echo ========
echo Test 125
echo ========
echo
echo ==========================================================
echo  Matched case-control study data from
echo  Trichopoulos et al. (1976) Br J Obs Gynaec 83: 645-650.
echo
echo  Results from R 2.7.0 are:
echo              coef    exp(coef) se(coef)  z       p
echo  spontaneous 1.985876  7.29    0.352443 5.63 1.8e-08
echo  induced     1.409012  4.09    0.360712 3.91 9.4e-05
echo 
echo  Likelihood ratio test=53.15424 on 2 df, p=2.87e-12 n= 248 
echo  Score test=48.43865
echo
echo ==========================================================
echo
clr case = spontaneous induced
echo
clear
!
! Allelic association but only weak evidence for linkage to the 
! Apolipoprotein locus in late-onset Swedish Alzheimer families
!
! Liu et al Am J Med Genet (Neuropsychiatr Genet) 1996; 67: 306-311
!
! 15 families as drawn Figure 1 (pp 307-308)
!
set loc ad aff
set loc onset qua
set loc apoe mar
read ped inline
F100 101   x   x m n  x x x
F100 102   x   x f y  x x x
F100 201 101 102 f y  x x x
F100 202   x   x m n  x x x
F100 203 101 102 m y 70 4 4
F100 204   x   x f n 82 3 3
F100 205 101 102 m y 72 3 4
F100 301 202 201 f n 46 4 4
F100 302 203 204 m n 49 3 4
F100 303 203 204 m n 44 3 4
F102 101   x   x m n  x x x
F102 102   x   x f y  x x x
F102 201   x   x m n  x x x
F102 202 101 102 f n 91 3 3
F102 203 101 102 f y 83 3 3
F102 204   x   x m n  x x x
F102 301 201 202 f n  x x x
F102 302   x   x m n  x x x
F102 303 204 203 f n 63 3 3
F102 304   x   x f n 60 3 3
F102 305 204 203 m y 52 3 4
F102 306   x   x m n  x x x
F102 307 204 203 f n 55 3 4
F102 401 302 303 m n  x x x
F102 402 302 303 f n  x x x
F102 403 302 303 m n  x x x
F102 404 305 304 m n 40 3 3
F102 405 306 307 f n  x x x
F102 406 306 307 m n  x x x
F104 101   x   x m n  x x x
F104 102   x   x f n  x x x
F104 201 101 102 f y  x x x
F104 202 101 102 f n  x x x
F104 203 101 102 f n  x x x
F104 204   x   x m n  x x x
F104 205 101 102 m n  x x x
F104 206   x   x f n  x x x
F104 207 101 102 f y 79 3 4
F104 208   x   x m n  x x x
F104 209 101 102 m y  x x x
F104 210   x   x f n  x x x
F104 211 101 102 f y 79 3 4
F104 212 101 102 m n  x x x
F104 213 101 102 m n  x x x
F104 214 101 102 f n  x x x
F104 215 101 102 f n 77 3 4
F104 301 204 203 m n  x x x
F104 302 204 203 f n  x x x
F104 303 205 206 f n  x x x
F104 304 205 206 f n  x x x
F104 305 208 207 f n 71 3 3
F104 306   x   x m n  x x x
F104 307 208 207 f n 67 3 3
F104 308   x   x m n  x x x
F104 309 209 210 f n  x x x
F104 310   x   x m n  x x x
F104 311 209 210 f n  x x x
F104 312   x   x m n  x x x
F104 401 306 305 f n  x x x
F104 402 306 305 m n  x x x
F104 403 308 307 f n  x x x
F104 404 308 307 m n  x x x
F104 405 310 309 f n  x x x
F104 406 312 311 f n  x x x
F106 101   x   x m n  x x x
F106 102   x   x f n  x x x
F106 201 101 102 m y  x x x
F106 202   x   x f n 86 3 3
F106 203 101 102 f y 80 2 4
F106 204   x   x m n  x x x
F106 205 101 102 f y  x x x
F106 206   x   x m n  x x x
F106 207 101 102 f y  x x x
F106 208 101 102 f y 60 4 4
F106 209   x   x m n  x x x 
F106 210 101 102 m y 70 3 4
F106 211   x   x f n 80 3 3 
F106 212 101 102 m n 80 2 3
F106 213   x   x f n 79 2 4 
F106 301 201 202 m n 63 3 4
F106 302 201 202 m n  x x x
F106 303 201 202 f n 61 3 3
F106 304 204 203 m n 51 3 4
F106 305 204 203 f n 51 2 3
F106 306 206 207 m n  x x x
F106 307 206 207 f n  x x x
F106 308 209 208 f n 60 3 4
F106 309 210 211 f n 55 3 4
F106 310 210 211 m n 50 3 3
F106 311 210 211 m n 48 3 3
F106 312 212 213 m n 49 2 3
F106 313 212 213 f n  x x x
F107 101   x   x m n  x x x
F107 102   x   x f y  x x x
F107 201 101 102 m n 84 3 3
F107 202 101 102 f y  x x x
F107 203 101 102 f y 69 3 4
F107 204 101 102 f n 63 4 4 
F107 205 101 102 m y 67 3 4
F107 206 101 102 m n 70 4 4
F107 207 101 102 f y 58 4 4
F107 208 101 102 f y 57 3 4
F107 209 101 102 m n 59 3 3
F118 101   x   x m n  x x x
F118 102   x   x f y  x x x
F118 201 101 102 f y  x x x
F118 202 101 102 m n  x x x
F118 203 101 102 f y  x x x
F118 204 101 102 m n 91 3 4
F118 205 101 102 m n  x x x
F118 206 101 102 m n  x x x
F118 207   x   x f n  x x x
F118 208 101 102 f y  x x x
F118 209   x   x m n  x x x
F118 210 101 102 f y 76 4 4
F118 211   x   x m n  x x x
F118 212 101 102 f y  x x x
F118 213   x   x m n  x x x
F118 214 101 102 f y 60 4 4
F118 215   x   x m n  x x x
F118 301 206 207 m n  x x x
F118 302 206 207 m n  x x x
F118 303 209 208 f n  x x x
F118 304 209 208 f n 39 3 3
F118 305 211 210 f n  x x x
F118 306 213 212 f n  x x x
F118 307 213 212 f n  x x x
F118 308 213 212 f n 46 4 4
F118 309 215 214 m n  x x x
F118 310 215 214 m n  x x x
F118 311 215 214 m n  x x x
F118 312 215 214 f n  x x x
F118 313 215 214 f n  x x x
F133 101   x   x m n  x x x
F133 102   x   x f y  x x x
F133 201 101 102 f y  x x x
F133 202   x   x m n  x x x
F133 203 101 102 m y  x x x
F133 204   x   x f n  x x x
F133 301 202 201 f n  x x x
F133 302 202 201 m y  x x x
F133 303   x   x f n  x x x
F133 304 202 201 m y  x x x
F133 305 202 201 m y  x x x
F133 306 202 201 m y 76 3 4
F133 307 202 201 m n  x x x
F133 308 202 201 f n  x x x
F133 309 202 201 f n 60 3 3
F133 310 203 204 m n 76 2 4
F133 311 203 204 m n 71 2 3
F133 312 203 204 m y 61 4 4
F133 313 203 204 m n 67 2 3
F133 401 302 303 m n  x x x
F151 101   x   x m n  x x x
F151 102   x   x f y  x x x
F151 201   x   x f n 80 3 3
F151 202 101 102 m y 76 3 3
F151 203 101 102 m x 78 3 3
F151 204   x   x f n 72 3 3
F151 205 101 102 m y 67 3 4
F151 206   x   x f n 74 3 3
F151 207 101 102 m y 60 3 4
F151 208   x   x f n 69 3 3
F151 209 101 102 m n 74 3 3
F151 210   x   x f n  x x x
F151 211 101 102 f n 71 3 3
F151 212   x   x m n  x x x
F151 213 101 102 m x 68 3 4
F151 214   x   x f n 72 4 4
F151 215 101 102 m n  x x x
F151 301 202 201 f n 59 3 3
F151 302   x   x m n  x x x
F151 303 203 204 m n 46 3 3
F151 304 203 204 m n 44 3 3
F151 305 205 206 m n  x x x
F151 306 205 206 f n 50 3 3
F151 307 207 208 f n 43 3 3
F151 308 209 210 f n 45 3 4
F151 309 209 210 f n 41 3 4
F151 310   x   x f n  x x x
F151 311 212 211 m n 52 3 3
F151 312 212 211 f n 47 3 3
F151 313   x   x m n 50 3 3
F151 314 213 214 f n 36 4 4
F151 315 213 214 f n 31 3 4
F151 401 302 301 m n 36 3 3
F151 402 311 310 f n 31 3 3
F151 403 313 312 f n 25 3 3
F163 101   x   x m n  x x x
F163 102   x   x f y  x x x
F163 201 101 102 f n 94 3 3
F163 202   x   x m n  x x x
F163 203 101 102 m n  x x x
F163 204   x   x f n  x x x
F163 205 101 102 f y 73 3 4
F163 206   x   x m n  x x x
F163 207 101 102 f n  x x x
F163 208   x   x m n  x x x
F163 209 101 102 f y 76 3 3
F163 210   x   x m n  x x x
F163 211 101 102 f y 76 3 4
F163 212   x   x m n  x x x
F163 213 101 102 f n 76 3 4
F163 214   x   x m n  x x x
F163 215 101 102 f y 59 3 4
F163 216   x   x m n  x x x
F163 301 202 201 m n 67 3 3
F163 302 202 201 f n 71 3 3
F163 303 202 201 f n 73 3 3
F163 304 203 204 m n 50 3 3
F163 305 203 204 m n  x x x
F163 306 206 205 f n 56 3 4
F163 307 206 205 f n 55 3 3
F163 308 206 205 m n 54 4 4 
F163 309 206 205 f n 52 3 3
F163 310 206 205 m n 51 3 4
F163 311 206 205 m n 49 3 4
F163 312 208 207 m n 53 3 4
F163 313 210 209 m n 47 3 4
F163 314 210 209 f n 44 3 4
F163 315 212 211 m n 53 2 4
F163 316 214 213 f n 43 3 4
F163 317 214 213 m n 48 3 3
F163 318 214 213 m n 35 3 4
F163 319 216 215 f n 47 3 3
F163 320 216 215 f n 35 3 4
F164 101   x   x m n  x x x
F164 102   x   x f n  x x x
F164 201 101 102 m n  x x x
F164 202 101 102 f y  x x x
F164 203 101 102 m n  x x x
F164 204 101 102 m n  x x x
F164 205 101 102 f n  x x x
F164 206 101 102 m n  x 3 3
F164 207 101 102 f y 65 3 4
F164 208   x   x m n  x x x
F164 209 101 102 f n  x x x
F164 210 101 102 f y 67 3 4
F164 211 101 102 m n 57 3 4
F164 212 101 102 f n 55 3 4
F164 213 101 102 f n 50 3 3
F164 214 101 102 m y  x x x
F164 301 208 207 f n  x x x
F164 302 208 207 f n  x x x
F175 101   x   x m y  x x x
F175 102   x   x f n  x x x
F175 201 101 102 m n  x x x
F175 202   x   x f n  x x x
F175 301 201 202 m y 69 2 3
F175 302 201 202 m y 62 3 3
F175 303 201 202 m y 60 3 3
F175 304 201 202 m n 70 3 3
F175 305 201 202 m n 69 2 3
F175 306 201 202 m n 61 2 4
F176 101   x   x m n  x x x
F176 102   x   x f y  x x x
F176 201   x   x m n  x x x
F176 202 101 102 f y  x x x
F176 203 101 102 f y 65 3 3
F176 301 201 202 f y 65 4 4
F176 302 201 202 f y  x x x
F176 303 201 202 m y 65 4 4
F176 304 201 202 m y 72 4 4
F176 305 201 202 f n 70 4 4
F176 306 201 202 f n 66 3 4
F176 307 201 202 m x 65 3 4
F176 308 201 202 m n 61 3 4
F197 101   x   x m n  x x x
F197 102   x   x f y  x x x
F197 201 101 102 m n  x x x
F197 202   x   x f n  x x x
F197 203 101 102 m y 65 3 4
F197 204 101 102 f n  x x x
F197 205 101 102 m n  x x x
F197 206 101 102 f y 72 3 3
F197 207   x   x m n 84 3 3
F197 208 101 102 m n  x x x
F197 209 101 102 m n 74 3 4
F197 210   x   x f n  x x x
F197 211 101 102 m n  x x x
F197 212 101 102 f n 71 3 3
F197 213 101 102 f n 69 3 3
F197 214   x   x m n  x x x
F197 215 101 102 m y 61 3 4
F197 216   x   x f n 62 2 4
F197 217 101 102 f n  x x x
F197 301 203 202 m n 49 3 3
F197 302 207 206 f n 52 3 3
F197 303 207 206 f n 51 3 3
F197 304 207 206 m n 48 3 3
F197 305 207 206 m n 47 3 3
F197 306 209 210 f n 47 3 3
F197 307 214 213 m n 37 3 3
F197 308 215 216 f n 35 4 4
F197 309 215 216 m n 29 2 3
F204 101   x   x m y  x x x
F204 102   x   x f n  x x x
F204 201 101 102 f y 69 4 4
F204 202   x   x m n  x x x
F204 203   x   x m n  x x x
F204 204 101 102 f y 70 4 4
F204 205 101 102 f y 72 3 4
F204 206 101 102 m y  x x x
F204 207 101 102 m n  x x x
F204 208   x   x m n  x x x
F204 209 101 102 f n 71 4 4
F204 210 101 102 f n 66 3 4
F204 301 202 201 f n 47 3 4
F204 302 202 201 f n 48 3 4
F204 303 203 204 m n 46 3 4
F204 304 203 204 m n 46 3 4
F204 305 208 209 m n 34 3 4
F204 306 208 209 m n 36 3 4
F205 101   x   x m y  x x x
F205 102   x   x f n  x x x
F205 201   x   x f n  x x x
F205 202 101 102 m y  x x x
F205 203 101 102 f n  x x x
F205 301 202 201 f y 67 3 4
F205 302   x   x m n  x x x
F205 303 202 201 f y 72 3 4
F205 304 202 201 f y 70 3 4
F205 305   x   x m n  x x x
F205 306 202 201 m n 73 3 4
F205 307   x   x m n  x x x
F205 308 202 201 f y 68 3 4
F205 309 202 201 f n 67 3 4
F205 401 302 301 m n 48 4 4
F205 402 302 301 m n 46 4 4
F205 403 305 304 m n 49 3 4
F205 404 305 304 m n 55 3 4
F205 405 307 308 m n 47 3 3
F205 406 307 308 f n 51 3 3
F205 407 307 308 m n 57 3 3
;;;;
run
echo
echo ========
echo Test 126
echo ========
sdt ad
echo
echo ========
echo Test 127
echo ========
ass ad
clear
echo 
echo Testing FBAT type statistic versus examples of the different types
echo of nuclear family:
echo 
set ple -1 silent
set seeds 1324 12345 15125
set loc trait aff
set loc marker mar
read ped inline
table1.1 1 x x m x A/A
table1.1 2 x x f x x/x
table1.1 3 1 2 m y A/A
table1.1 4 1 2 m n A/A
table1.2 1 x x m x A/A
table1.2 2 x x f x x/x
table1.2 3 1 2 m y A/A
table1.2 4 1 2 m n A/B
table1.2 5 1 2 m n A/B
table1.3 1 x x m x A/A
table1.3 2 x x f x x/x
table1.3 3 1 2 m y A/B
table1.3 4 1 2 m n A/C
table1.3 5 1 2 m n A/C
table2.1 1 x x m x A/B
table2.1 2 x x f x x/x
table2.1 3 1 2 m y A/A
table2.1 4 1 2 m y A/A
table2.2 1 x x m x A/B
table2.2 2 x x f x x/x
table2.2 3 1 2 m y A/A
table2.2 4 1 2 m y A/A
table2.2 5 1 2 m y A/A
table2.2 6 1 2 m n A/B
table2.2 7 1 2 m n A/B
table2.3 1 x x m x A/B
table2.3 2 x x f x x/x
table2.3 3 1 2 m y A/A
table2.3 4 1 2 m n B/B
table2.3 5 1 2 m n B/B
table2.4 1 x x m x A/B
table2.4 2 x x f x x/x
table2.4 3 1 2 m y A/C
table2.4 4 1 2 m y B/C
table2.4 5 1 2 m y B/C
table2.4 6 1 2 m y B/C
table2.5 1 x x m x A/B
table2.5 2 x x f x x/x
table2.5 3 1 2 m y A/B
table2.5 4 1 2 m y A/C
table2.5 5 1 2 m y A/C
table2.5 6 1 2 m n B/C
table2.6 1 x x m x A/B
table2.6 2 x x f x x/x
table2.6 3 1 2 m y A/A
table2.6 4 1 2 m y A/A
table2.6 5 1 2 m n A/C
table2.6 6 1 2 m n B/C
table2.7 1 x x m x A/B
table2.7 2 x x f x x/x
table2.7 3 1 2 m y A/C
table2.7 4 1 2 m n B/D
table2.7 5 1 2 m n B/C
table3.2 1 x x m x x/x
table3.2 2 x x f x x/x
table3.2 3 1 2 m y A/A
table3.2 4 1 2 m y A/A
table3.2 5 1 2 m n A/B
table3.2 6 1 2 m n A/B
table3.2 7 1 2 m n A/B
table3.3 1 x x m x x/x
table3.3 2 x x f x x/x
table3.3 3 1 2 m y A/A
table3.3 4 1 2 m n A/B
table3.3 5 1 2 m n B/B
table3.3 6 1 2 m n B/B
table3.4 1 x x m x x/x
table3.4 2 x x f x x/x
table3.4 3 1 2 m y A/B
table3.4 4 1 2 m y A/C
table3.4 5 1 2 m n B/C
table3.4 6 1 2 m n B/C
table3.5 1 x x m x x/x
table3.5 2 x x f x x/x
table3.5 3 1 2 m y A/B
table3.5 4 1 2 m n A/C
table3.6 1 x x m x x/x
table3.6 2 x x f x x/x
table3.6 3 1 2 m y A/B
table3.6 4 1 2 m n B/C
table3.6 5 1 2 m n B/C
table3.6 6 1 2 m n B/C
table3.6 7 1 2 m n B/C
table3.7 1 x x m x x/x
table3.7 2 x x f x x/x
table3.7 3 1 2 m y A/C
table3.7 4 1 2 m n B/C
table3.7 5 1 2 m n B/D
table3.7 6 1 2 m n B/D
;;;;
run
macro testfbat
 sel ped table%1
 set ple 1
 ass trait
 set ple -1
 uns
;;;;
set iter 5000
echo
echo ========
echo Test 128
echo ========
echo
echo Family type 1.1
echo Expect No useful sibships
testfbat 1.1
echo
echo ========
echo Test 129
echo ========
echo
echo Family type 1.2
echo Expect A  2.0000  E=1.5000  V=  0.2500  -0.2500   
echo Expect B  0.0000  E=0.5000  V= -0.2500   0.2500    
testfbat 1.2
echo
echo ========
echo Test 130
echo ========
echo
echo Family type 1.3
echo Expect A  1.0000  E=1.0000  V=0.0000   0.0000   0.0000    
echo Expect B  1.0000  E=0.5000  V=0.0000   0.2500  -0.2500   
echo Expect C  0.0000  E=0.5000  V=0.0000  -0.2500   0.2500    
testfbat 1.3
echo
echo ========
echo Test 131
echo ========
echo
echo Family type 2.1
echo Expect No useful sibships
testfbat 2.1
echo
echo ========
echo Test 132
echo ========
echo
echo Family type 2.2
echo Expect A  6.0000  E=4.8000  V= 0.3600  -0.3600   
echo Expect B  0.0000  E=1.2000  V=-0.3600   0.3600    
testfbat 2.2
echo
echo ========
echo Test 133
echo ========
echo
echo Family type 2.3
echo Expect A  2.0000  E=1.0000  V= 0.7778  -0.7778   
echo Expect B  0.0000  E=1.0000  V=-0.7778   0.7778    
testfbat 2.3
echo
echo ========
echo Test 134
echo ========
echo
echo Family type 2.4
echo Expect A  1.0000  E=2.0000  V= 1.0000  -1.0000  0.0000    
echo Expect B  3.0000  E=2.0000  V=-1.0000   1.0000  0.0000    
echo Expect C  4.0000  E=4.0000  V= 0.0000   0.0000  0.0000    
testfbat 2.4
echo
echo ========
echo Test 135
echo ========
echo
echo Family type 2.5
echo Expect A  3.0000  E=2.1094  V= 0.5662  -0.3245 -0.2417   
echo Expect B  1.0000  E=2.1094  V=-0.3245   0.5662 -0.2417   
echo Expect C  2.0000  E=1.7812  V=-0.2417  -0.2417  0.4834    
testfbat 2.5
echo
echo ========
echo Test 136
echo ========
echo
echo Family type 2.6
echo Expect A  4.0000  E=2.2375  V= 0.9436  -0.4864 -0.4572   
echo Expect B  0.0000  E=0.8375  V=-0.4864   0.4486  0.0378    
echo Expect C  0.0000  E=0.9250  V=-0.4572   0.0378  0.4194    
testfbat 2.6
echo
echo ========
echo Test 137
echo ========
echo
echo Family type 2.7
echo Expect A  1.0000  E=0.5000  V= 0.2500  -0.2500  0.0000  0.0000    
echo Expect B  0.0000  E=0.5000  V=-0.2500   0.2500  0.0000  0.0000    
echo Expect C  1.0000  E=0.5000  V= 0.0000   0.0000  0.2500 -0.2500   
echo Expect D  0.0000  E=0.5000  V= 0.0000   0.0000 -0.2500  0.2500    
testfbat 2.7
echo
echo ========
echo Test 138
echo ========
echo
echo Family type 3.2
echo Expect A  4.0000  E=2.8000  V= 0.3600  -0.3600   
echo Expect B  0.0000  E=1.2000  V=-0.3600   0.3600    
testfbat 3.2
echo
echo ========
echo Test 139
echo ========
echo
echo Family type 3.3
echo Expect A  2.0000  E=1.0000  V= 0.6727  -0.6727   
echo Expect B  0.0000  E=1.0000  V=-0.6727   0.6727    
testfbat 3.3
echo
echo ========
echo Test 140
echo ========
echo
echo Family type 3.4
echo Expect A  2.0000  E=1.3333  V= 0.3333  -0.1667  -0.1667   
echo Expect B  1.0000  E=1.3333  V=-0.1667   0.3333  -0.1667   
echo Expect C  1.0000  E=1.3333  V=-0.1667  -0.1667   0.3333    
testfbat 3.4
echo
echo ========
echo Test 141
echo ========
echo
echo Family type 3.5
echo Expect A  1.0000  E=1.0000  V=0.0000    0.0000   0.0000    
echo Expect B  1.0000  E=0.5000  V=0.0000    0.2500  -0.2500   
echo Expect C  0.0000  E=0.5000  V=0.0000   -0.2500   0.2500    
testfbat 3.5
echo
echo ========
echo Test 142
echo ========
echo
echo Family type 3.6
echo Expect A  1.0000  E=0.5000  V= 0.2500   0.0000  -0.2500   
echo Expect B  1.0000  E=1.0000  V= 0.0000   0.0000   0.0000    
echo Expect C  0.0000  E=0.5000  V=-0.2500   0.0000   0.2500    
testfbat 3.6
echo
echo ========
echo Test 143
echo ========
echo
echo Family type 3.7
echo Expect A  1.0000  E=0.5000  V= 0.2500  -0.2500   0.0000  0.0000    
echo Expect B  0.0000  E=0.5000  V=-0.2500   0.2500   0.0000  0.0000    
echo Expect C  1.0000  E=0.5000  V= 0.0000   0.0000   0.2500 -0.2500   
echo Expect D  0.0000  E=0.5000  V= 0.0000   0.0000  -0.2500  0.2500    
testfbat 3.7
clear
echo 
echo Testing GPEs:
echo 
set imp
set ple -1
set seeds 1324 1345 15125
set loc published qua
read pedigree inline
hops 1   0   0   1  0.197
hops 2   0   0   2  0.099
hops 3   0   0   1  0.109
hops 4   0   0   2  0.109
hops 6   0   0   2  0.105
hops 7   0   0   1  0.113
hops 13  0   0   1  x
hops 14  0   0   2  x
hops 17  0   0   1  0.061
hops 18  0   0   2  0.055
hops 24  0   0   2  x
hops 25  0   0   1  x
hops 26  0   0   2  x
hops 31  0   0   1  x
hops 32  0   0   2  x
hops 36  0   0   2  x
hops 37  0   0   1  x
hops 39  0   0   1  x
hops 41  0   0   1  x
hops 42  0   0   2  x
hops 50  0   0   2  x
hops 51  0   0   1  x
hops 56  0   0   2  0.057
hops 57  0   0   1  0.059
hops 58  0   0   2  0.055
hops 70  0   0   2  x
hops 96  0   0   2  x
hops 100 0   0   1  x
hops 101 0   0   2  x
hops 270 0   0   1  x
hops 271 0   0   1  x
hops 108 0   0   2  x
hops 113 0   0   1  x
hops 114 0   0   2  x
hops 125 0   0   2  x
hops 126 0   0   1  x
hops 148 0   0   1  x
hops 162 0   0   1  x
hops 172 0   0   1  x
hops 173 0   0   2  x
hops 199 0   0   1  x
hops 200 0   0   2  x
hops 201 0   0   1  x
hops 204 0   0   2  x
hops 206 0   0   2  x
hops 220 0   0   2  x
hops 231 0   0   2  x
hops 249 0   0   2  x
hops 5   3   4   1  x
hops 8   7   6   2  x
hops 9   5   8   1  x
hops 10  9   2   2  x
hops 11  1   10  1  x
hops 12  7   6   2  x
hops 15  13  14  1  x
hops 16  15  12  2  x
hops 19  17  18  1  x
hops 20  3   4   2  x
hops 21  19  20  1  x
hops 22  21  16  2  x
hops 23  7   6   1  x
hops 27  25  26  1  x
hops 28  27  24  2  x
hops 29  23  28  1  x
hops 30  29  22  2  x
hops 33  31  32  1  x
hops 34  27  24  2  x
hops 35  33  34  1  x
hops 38  37  36  2  x
hops 40  39  38  2  x
hops 43  41  42  1  x
hops 44  13  14  2  x
hops 45  43  44  1  x
hops 46  45  40  2  x
hops 47  35  46  1  x
hops 48  47  30  2  x
hops 49  11  48  1  x
hops 52  51  50  2  x
hops 53  3   4   1  x
hops 54  17  18  2  x
hops 55  53  54  1  x
hops 59  57  58  1  x
hops 60  59  56  2  x
hops 61  55  60  1  x
hops 62  61  52  2  x
hops 63  21  16  1  x
hops 64  5   8   2  x
hops 65  63  64  1  x
hops 66  65  62  2  x
hops 67  49  66  1  x
hops 68  1   10  2  x
hops 69  61  52  1  x
hops 71  57  58  1  x
hops 72  71  70  2  x
hops 73  17  18  1  x
hops 74  73  72  2  x
hops 75  37  36  1  x
hops 76  7   6   2  x
hops 77  59  76  2  x
hops 78  75  77  1  x
hops 79  78  74  2  x
hops 80  71  70  1  x
hops 81  80  34  1  x
hops 82  5   8   2  x
hops 83  81  82  1  x
hops 84  83  79  2  x
hops 85  69  84  1  x
hops 86  85  68  2  x
hops 87  67  86  1  x
hops 88  81  82  2  x
hops 89  73  72  1  x
hops 90  31  32  1  x
hops 91  90  60  2  x
hops 92  89  91  1  x
hops 93  92  88  2  x
hops 94  71  70  2  x
hops 95  23  94  1  x
hops 97  95  96  1  x
hops 98  7   6   2  x
hops 99  71  98  2  x
hops 102 100 101 1  x
hops 103 102 99  2  x
hops 104 97  103 1  x
hops 105 75  77  2  x
hops 106 270 42  2  x
hops 107 271 106 1  x
hops 109 107 108 1  x
hops 110 109 105 2  x
hops 111 100 101 1  x
hops 112 17  18  2  x
hops 115 113 114 1  x
hops 116 115 112 2  x
hops 117 111 116 1  x
hops 118 117 40  1  x
hops 119 118 110 2  x
hops 120 104 119 1  x
hops 121 120 93  2  x
hops 122 1   10  1  x
hops 123 63  64  2  x
hops 124 73  72  1  x
hops 127 126 125 2  x
hops 128 7   6   1  x
hops 129 128 127 2  x
hops 130 124 129 1  x
hops 131 39  38  2  x
hops 132 59  56  1  x
hops 133 132 131 2  x
hops 134 130 133 1  x
hops 135 134 123 2  x
hops 136 122 135 1  x
hops 137 136 121 2  x
hops 138 87  137 1  x
hops 139 122 135 1  x
hops 140 120 93  2  x
hops 141 139 140 1  x
hops 142 85  68  2  x
hops 143 49  66  1  x
hops 144 143 142 2  x
hops 145 141 144 2  x
hops 163 43  44  2  x
hops 191 33  34  1  x
hops 192 5   8   2  x
hops 193 191 192 1  x
hops 194 162 163 2  x
hops 202 201 200 2  x
hops 203 199 202 1  x
hops 205 17  18  1  x
hops 207 113 114 1  x
hops 208 207 206 2  x
hops 209 205 208 1  x
hops 218 61  52  1  x
hops 219 172 173 2  x
hops 221 162 220 1  x
hops 222 221 219 2  x
hops 223 53  54  2  x
hops 224 203 223 1  x
hops 225 224 222 2  x
hops 226 218 225 1  x
hops 227 1   10  2  x
hops 228 226 227 1  x
hops 229 209 204 2  x
hops 230 73  72  1  x
hops 232 230 231 1  x
hops 233 232 229 2  x
hops 234 172 173 2  x
hops 235 78  234 1  x
hops 236 235 233 2  x
hops 237 134 123 1  x
hops 238 237 236 2  x
hops 239 228 238 1  x
hops 240 193 194 2  x
hops 241 132 131 1  x
hops 242 115 112 2  x
hops 243 3   4   1  x
hops 244 126 125 2  x
hops 245 243 244 1  x
hops 246 245 242 2  x
hops 247 241 246 1  x
hops 248 75  77  2  x
hops 250 148 249 1  x
hops 251 250 248 2  x
hops 252 247 251 1  x
hops 253 252 240 2  x
hops 254 92  88  1  x
hops 255 134 123 2  x
hops 256 254 255 1  x
hops 257 256 253 2  x
hops 258 239 257 1  x
hops 259 237 236 1  x
hops 260 226 227 2  x
hops 261 259 260 1  x
hops 262 237 236 2  x
hops 263 252 240 1  x
hops 264 263 262 2  x
hops 265 104 119 1  x
hops 266 218 225 2  x
hops 267 265 266 1  x
hops 268 267 264 2  x
hops 269 261 268 2  x
hops 273 138 145 1  x
hops 275 258 269 1  x 
;;;;
run
set imp -1
set loc hops mar
set imp 0
echo
echo ========
echo Test 144
echo ========
echo
edit hops {273 275} hops "2/2"
set freq hops 1 0.99 2 0.01
let hops=hops+0
set iter 1000
set loc risk qua
gpe hops risk
set loc carrier1 qua
carrier1 = 1-0.5*risk

set imp full
write

gpe hops mcmc risk
write
set loc carrier2 qua
carrier2 = 1-0.5*risk
drop hops risk
echo
echo ========
echo Test 145
echo ========
echo
echo ======================================================
echo Table 1 from Lin, Thompson and Wijsman (1994). Ann Hum 
echo Genet 58: 353. Estimated posterior carrier probabilities, 
echo
echo conditional on the data, obtained by running
echo the heated-Metropolis algorithm, for the Hutterite pedigree 
echo and data in Figure 2
echo (Listed are only those founders whose posterior probabilities
echo of being carriers are estimated to be more than 5\%).
echo Founder Carrier       Standard 
echo label   probability   error
echo 1       0.197         0.012
echo 2       0.099         0.005
echo 3       0.109         0.006
echo 4       0.109         0.006
echo 6       0.105         0.010
echo 7       0.113         0.010
echo 17      0.061         0.005
echo 18      0.055         0.005
echo 56      0.057         0.004
echo 57      0.059         0.003
echo 58      0.055         0.004
echo
echo ======================================================
print published 
clear
echo
echo
echo Testing segregation analysis:
echo
echo Alaskan hypercholesterolemia pedigree used for example 12
echo in the MENDEL manual [Lange 1986]: age, log(sChol)
echo
echo Schrott HG, Goldstein JL, Hazzard WR, McGoodwin MM, Motulsky AG:
echo Familial hypercholesterolemia in a large kindred:  Evidence for a
echo monogenic mechanism.  Ann. Int. Med. 76:711-720, 1972
echo
set locus age qua
set locus logChol qua
read pedigree inline
1 101 x x f 62. x
1 102 x x m 87. 5.313206
1 201 102 101 f 38. x
1 202 x x m 51. 5.690359
1 203 102 101 m 47. 5.313206
1 204 x x f 36. 5.545177
1 205 102 101 m 41. x
1 206 x x f 41. 5.655992
1 207 102 101 m 38. x
1 208 x x f 38. 5.030438
1 209 102 101 f 38. x
1 210 x x m 38. x
1 212 102 101 m 41. 5.899897
1 213 x x f 35. 5.288267
1 214 102 101 f 39. 5.700444
1 215 x x m 47. 5.463832
1 216 102 101 m 38. 6.171701
1 217 x x f 36. 5.446737
1 218 102 101 f 36. 6.104793
1 219 x x m 35. 5.746203
1 220 102 101 m 35. 5.937536
1 221 x x f 28. 5.347108
1 222 102 101 m 32. 5.929589
1 223 x x f 27. 5.105945
1 224 102 101 m 30. 5.505332
1 225 x x f 26. 5.375278
1 226 x x m 28. x
1 227 102 101 f 28. 5.262690
1 228 x x m 48. 5.497168
1 229 102 101 m 27. 6.030685
1 230 102 101 m 26. 5.236442
1 231 102 101 m 24. 5.347108
1 232 102 101 m 22. 5.283204
1 233 x x f 19. 4.969813
1 301 202 201 m 31. 6.045005
1 302 x x f 30. 5.501258
1 303 202 201 m 30. 5.398163
1 304 x x f 29. 5.602119
1 305 202 201 m 29. 5.393628
1 306 x x f 26. 5.241747
1 307 202 201 m 26. 6.052089
1 308 202 201 m 25. 5.488938
1 309 202 201 f 24. 5.802118
1 311 202 201 f 22. 6.388561
1 312 x x m 23. 5.241747
1 313 202 201 f 21. 6.086775
1 314 x x m 21. x
1 315 202 201 m 20. 5.968708
1 316 202 201 m 16. 5.638355
1 317 202 201 f 15. 5.899897
1 318 203 204 f 12. 5.529429
1 319 203 204 f 11. 5.521461
1 320 203 204 m 10. 5.455321
1 322 203 204 m 6. 5.308268
1 323 205 206 f 25. 5.327876
1 325 205 206 m 22. 5.153292
1 326 207 208 m 20. 5.929589
1 327 207 208 m 17. 5.758902
1 328 210 209 f 22. 5.298317
1 329 210 209 f 20. 5.111988
1 330 x x m 20. x
1 331 210 209 f 12. 5.398163
1 332 210 209 m 8. 5.484797
1 333 210 209 f 6. 5.298317
1 334 212 213 m 20. 5.225747
1 335 212 213 f 17. 5.549076
1 336 212 213 m 16. 5.686975
1 337 212 213 m 15. 5.365976
1 338 212 213 f 4. 5.820083
1 339 215 214 m 20. 5.780744
1 340 215 214 f 19. 5.634790
1 341 215 214 f 15. 5.942799
1 342 215 214 m 12. 5.442418
1 343 215 214 f 10. 5.910797
1 344 216 217 m 18. 5.164786
1 345 216 217 f 17. 5.170484
1 346 216 217 f 16. 5.899897
1 347 216 217 m 14. 5.192957
1 348 216 217 m 13. 5.192957
1 349 216 217 m 11. 5.733341
1 350 216 217 f 10. 6.070738
1 351 216 217 f 6. 5.147494
1 352 216 217 m 1. 5.252273
1 353 219 218 m 16. 5.768321
1 354 219 218 f 13. 5.932245
1 355 219 218 m 10. 6.021023
1 356 219 218 f 4. 6.118097
1 357 220 221 m 8. 5.337538
1 358 220 221 m 6. 6.023448
1 359 220 221 f 5. 5.579730
1 360 222 223 f 8. 5.198497
1 361 222 223 f 6. 5.924256
1 362 224 225 f 6. 5.389072
1 363 224 225 f 4. 5.393628
1 364 224 225 m 2. 5.267858
1 365 226 227 f 5. 5.365976
1 367 232 233 m 2. 5.075174
1 368 232 233 f 1. 5.505332
1 401 301 302 m 12. 5.831882
1 402 301 302 f 9. 5.365976
1 403 301 302 m 5. 5.323010
1 404 303 304 f 7. 5.459586
1 405 303 304 m 5. 5.087596
1 406 303 304 f 0. 5.214936
1 407 305 306 m 8. 5.257495
1 408 305 306 f 7. 5.252273
1 410 312 311 f 1. 5.908083
1 411 314 313 m 1. 5.513429
1 414 330 329 m 2. 5.214936
;;;;
run
echo
echo ========
echo Test 146
echo ========
echo
echo  Variance Components analysis
echo
echo                   MENDEL             WOMBAT (REML)
echo  Predictor        Estimate   ASE     Estimate   ASE
echo  ---------------  --------   ------  --------   ------
echo  Mean               5.4104   0.0683  
echo  Total variance     0.1074
echo  Additive           0.0643   0.0283  0.067173   0.0314
echo  Environmental      0.0431   0.0172  0.044411   0.0190
echo  heritability       0.5990   0.1344
echo 
var logChol
echo
echo ========
echo Test 147
echo ========
echo
mix logChol 2
echo
echo Crude estimate increasing allele based on mixture model:
1-sqrt(0.6337)
echo
echo
echo ========
echo Test 148
echo ========
echo
set seeds 234 6324 24641
set burn 1000
set iter 1000
fpm logChol p a d fix d dval 1
echo
echo MENDEL and PAP give:
echo
echo  MLEs    Genotypic       Dominant
echo  1/1     6.137 (0.129)   5.915 (0.0302)
echo  1/2     5.885 (0.0325)  5.915 (0.0302)
echo  2/2     5.333 (0.0204)  5.339 (0.0213)
echo  SD      0.153 (0.0122)  0.160 (0.0122)
echo  FREQ-1  0.071 (0.0411)  0.063 (0.0418)
echo  -2LL    1.5727          3.6453
echo
echo ========
echo Test 149
echo ========
echo
echo 
echo One thousand nuclear families with 
echo three phenotyped offspring
echo 
clear
set seeds 234 6324 24641
set burn 1000
simulate pedigrees 1000 2 3 3
run
set loc marker mar
set loc hitrait aff
set loc qtrait qua
sim marker 0.6 0.4
if (marker=="1/1") then qtrait=rnorm else qtrait=rnorm+1
let hitrait = (qtrait > 0)
if (isfou) then (hitrait=x) (qtrait=x)
des hitrait
set mft 10000 0.001
mft hitrait ae
echo
echo ========
echo Test 150
echo ========
echo
echo Test for duplicates or MZ twins
echo
clear
set loc m1 mar
set loc m2 mar
set loc m3 mar
set loc m4 mar
set loc m5 mar
set loc m6 mar
set loc m7 mar
set loc m8 mar
set loc m9 mar
set loc m10 mar
set loc m11 mar
set loc m12 mar
read pedigree inline
1 1 x x m 1/1 1/2 1/2 2/2 1/2 1/1 1/2 2/2 2/2 2/2 1/2 1/1
1 2 x x m 1/1 1/2 1/2 2/2 1/2 1/1 1/2 2/2 2/2 2/2 1/2 2/2
;;;;
run
set twin err 0.15 12
test dup
sum
clear
echo
echo ========
echo Test 151
echo ========
echo
echo LD clumping 
echo
echo Drop m2 as redundant
echo
#      SNP       Assoc-P 
set loc m1 snp . 1e-12
set loc m2 snp . 2e-12
set loc m3 snp . 1e-7
read cases inline noid
A/A C/C A/C
A/C C/T A/A
A/C C/T A/C
C/C T/T C/C
;;;;
run
#
# transfer first column of annotation to locstat
# and declare as a P-value
#
sum get 1
eval (locstat-type! "pva")
set ple 2
clump nosave
set ple 0
clear
