Page 1
Performing the Exact Test of HardyWeinberg Proportion for Multiple Alleles
Author(s): Sun Wei Guo and Elizabeth A. Thompson
Source: Biometrics, Vol. 48, No. 2 (Jun., 1992), pp. 361372
Published by: International Biometric Society
Stable URL: http://www.jstor.org/stable/2532296
Accessed: 24/08/2010 10:31
Your use of the JSTOR archive indicates your acceptance of JSTOR's Terms and Conditions of Use, available at
http://www.jstor.org/page/info/about/policies/terms.jsp. JSTOR's Terms and Conditions of Use provides, in part, that unless
you have obtained prior permission, you may not download an entire issue of a journal or multiple copies of articles, and you
may use content in the JSTOR archive only for your personal, noncommercial use.
Please contact the publisher regarding any further use of this work. Publisher contact information may be obtained at
http://www.jstor.org/action/showPublisher?publisherCode=ibs.
Each copy of any part of a JSTOR transmission must contain the same copyright notice that appears on the screen or printed
page of such transmission.
JSTOR is a notforprofit service that helps scholars, researchers, and students discover, use, and build upon a wide range of
content in a trusted digital archive. We use information technology and tools to increase productivity and facilitate new forms
of scholarship. For more information about JSTOR, please contact support@jstor.org.
International Biometric Society is collaborating with JSTOR to digitize, preserve and extend access to
Biometrics.
http://www.jstor.org
Page 2
BIOMETRICS 48, 36 1372
June 1992
Performing the Exact Test of HardyWeinberg
for Multiple Alleles
Proportion
Sun Wei Guol * and Elizabeth A. Thompson"2
1 Department of Biostatistics, SC32,
2 Department of Statistics, GN22,
University of Washington, Seattle, Washington 98195, U.S.A.
SUMMARY
role in the field of population
Because of its importance,
proportions (HWP) over the decades. It has long been recognized
sample goodnessoffit tests can sometimes lead to spurious results
genotypic frequencies are small. Although
a complete enumeration
been proposed, it is not of practical use for loci with more than a few alleles due to the amount of
computation required. We propose two algorithms
HWP. The algorithms are easily applicable to loci with multiple
and computationally
fast. Relative efficiency and merits of the two algorithms
Guidelines regarding their usage are given. Numerical
of the algorithms.
The HardyWeinberg
as a basis for genetic inference.
of HardyWeinberg
law plays an important
genetics
has been devoted to tests
and often serves
much attention
that large
when the sample size and/or some
algorithm
for the exact test has
to estimate the significance
alleles. Both are remarkably
level for a test of
simple
are compared.
the practicality
examples are given to illustrate
1. Introduction
The importance of the HardyWeinberg law in the development of population genetics
cannot be overstated (see, for example, Crow, 1988). This law says that in a large random
mating population with no selection, mutation, or migration, the allele frequencies and the
genotype frequencies are constant from generation to generation and that, furthermore,
there is a simple relationship between the allele frequencies and the genotype frequencies.
For an mallele autosomal locus with alleles Al, A2, ...
by the HardyWeinberg law is
, A,,1, the genotypic array as given
pA jAA, + E 2pipjA Ai,
where pi is the allelic frequency of Ai. A population with these genotype frequencies is said
to be in HardyWeinberg equilibrium at the locus under investigation; the genotype
frequencies are known as HardyWeinberg proportions (HWP). Because of its importance,
testing of the hypothesis that a population exhibits HWP has drawn a lot of attention
during past decades, though the problem itself seems to be very simple from a statistical
viewpoint.
The methods proposed so far for testing HWP can be categorized into two groups. One
consists of largesample goodnessoffit tests such as Pearson's x2, likelihood ratio statistic
* Current
Arbor, Michigan 48109, U.S.A.
Key words: Exact tests; HardyWeinberg;
Multiple alleles.
address. Department
of Biostatistics,
University
of Michigan, 109 S. Observatory,
Ann
Markov chain; Metropolis algorithm;
Monte Carlo;
361
Page 3
362
Biometrics, June 1992
G2, and conditional x2 test (Li, 1955). These tests have one characteristic
They lean heavily on asymptotic
results.
1949; Haldane, 1954; Chapco, 1976). These tests usually involve a lot of computing
were, in the past, thus restricted to diallelic locus with small sample sizes due to lack of
computing power. It has long been recognized
sometimes
lead to false rejection or acceptance of HWP when the sample sizes are small
and/or some cell frequencies
are small or zero (see, for example, Emigh, 1980). Although
various corrections for small sample sizes are made (Emigh and Kempthorne,
and Forthofer,
1977; Smith, 1986), it is found that they usually do not greatly
results obtained from the traditional
goodnessoffit
Weir, 1989). Thus an exact test is preferred
when the sample size is small and/or some cell
frequencies are small or zero.
On the other hand, with the advent of the restriction
(RFLP) and variable number of tandem repeats (VNTRs), genetic loci with 10 or more
alleles are not uncommon nowadays (Botstein et al., 1980; Nakamura et al., 1987). Hence,
even if the sample size is moderately
large, the number of genotypes
sample genotype frequencies
will be zero, especially when the corresponding
allele frequencies are low (Figure 1). As a result,
offit tests of HWP is questionable
and use of the exact test is desirable.
in common:
The other approach involves exact tests (Levene,
and
that the standard goodnessoffit tests can
1975; Elston
improve the
tests (Emigh, 1980; Hernindez and
fragment length polymorphism
is so large that some
population
classical goodness the adequacy of applying
Al
3
A2
4 2
A3 2
2 2
A4
3 3
2
1
A5
0
1
0 0
0
A6
0
0 0 0
0
1
A7
0 0
1
0
0
0
0
A8
0 0
0
2
1
0
0
0
Al A2 A3 A4 A5 A6 A7 A8
Figure 1. A sample of size 30.of genotype
frequencies
are (.2, .2, .2, .2, .05, .05, .05, .05).
simulated under HWP when the underlying
gene frequencies
Louis and Dempster (1987) proposed an algorithm
of a finite sample drawn from a population in HWP. The algorithm
number of alleles is low (say, four or five) but it will be too computerintensive
of practical use when there are many alleles since the number of possible samples with
same gene frequencies
and sample sizes grows exponentially
(Herndndez and Weir, 1989). To avoid complete enumeration,
suggest use of a conventional
Monte Carlo method to obtain an estimated
however,
a general algorithm to perform
the test of HWP using Monte Carlo methods has
not been available.
for generating
the exact distribution
works well when the
to be
with the number of alleles
Herndndez and Weir
Pvalue. So far,
Page 4
Monte Carlo Test of Hardy Weinberg
363
In this paper, we present two methods to estimate the exact significance
exact test for HWP for multiple alleles. One is a conventional
to Joe Felsenstein (personal communication),
Metropolis algorithm
long known in statistical
Heermann, 1988). Whereas the former
mating can be regarded as random union of two gametes, the crux of the latter is the
construction
of a Markov chain with equilibrium distribution
probabilities
under HWP of samples that have the same allelic counts as the observed
The method can be regarded as a variant of the one proposed by Guo and Thompson
(Technical Report # 187, Department
of Statistics,
analysis of sparse contingency
tables, which is, in turn, an extension of the approach of
Besag and Clifford
(1989) for binary
tables. In Section 2 we give some notation
(1949) distribution.
The algorithms
are presented
practicality of the method is demonstrated
by several examples in Section 5. The relative
merits
of two methods are discussed in Section 6. The programs
proposed in this paper are written
in C, to run under BSD4.3 UNIX. These programs
available free of charge from the authors upon request.
levels of the
Monte Carlo method, due
and the other is an adaptation of the
physics (Metropolis
et al., 1953; Binder and
method takes advantage of the fact that random
matching the genotype
data.
University of Washington,
1989) for the
and Levene's
in Sections 3 and 4, respectively.
The
implementing
the methods
are
2. Exact Test for m Alleles
Consider an autosomal locus that has m alleles A 1, A2 ...,
sampled from a population of interest,
A,,,. If a sample of size n is
as the array
the data can be presented
A I f, I
A2
121 ?22
A Mn fn
fn2
fnm
Al A2...
An
where f1 (1 j
we will use f = (f 1, ft2 , f22, . . . fa) to designate
(where
and conditional on fi, the probability
<
i , m) is the observed count of genotype
A Aj. Throughout
this table. 1ff = f, + f? = f' +
the paper,
k J1
f = ]' if J> i), thenf is the number of Ai alleles in the sample. Then, under HWP
of obtaining the sample f is (Levene, 1949):
Pf)=n!
Pr(f)(
fH If!
z!l4't2jziju
(2n)!
fHJ~fj!(1
P=
geJ,
(1)
The exact test for HWP given observed sample f has to evaluate
E Pr(g),
(2)
where
Y = {g: Pr(g) S Pr(f), g E Fol, and
Fo = F(f) = {g: g has the same allele counts {giI as does f}.
Rejection or acceptance of the null hypothesis
prespecified
significance
level a.
depends on whether
P is smaller than a
3. Conventional
Suppose a sample of size n is drawn from a population of interest
can visualize the genotypes
of these n individuals
Monte Carlo Method
and we have data f. We
by f A1gametes
formed
(i = 1, . .., m)
Page 5
364
Biometrics,
June 1992
in a particular manner. Under HWP, a sample of size n withfi Aigametes (i = 1, ...,
can be regarded as n random unions of two gametes. Thus, if the 2n gametes are first
arranged
in the following
manner,
m)
Iskg
,
f2
>
...
fn7
A Al ...
Al A2
A2
... A . .A,
A, i
A,,,
and then a random permutation
as a sample of size n drawn from a population under HWP, with f gametes of type Ai
(i = 1, .. ., m). If we permute and chop it into n pairs again, then the n pairs can be
regarded
as another random sample from the same population.
algorithm
to estimate
the Pvalue:
is applied, the n successive
pairs of alleles can be regarded
Thus we have the following
1. Compute Pr(f); set counter K = 0.
2. Construct index vector s, with si =
t
+
3. For specified
simulation
(i) Reset s to a random permutation
(ii) Obtain sample g by chopping s into n consecutive
g = {AS2k AS2k k = 1, 2, . . ., n}.
(iii) Calculate Pr(g).
(iv) If Pr(g) < Pr(f), add 1 to K.
4. The Monte Carlo Pvalue is K/N.
S2 =
= s = 1, Sj+
=
=
+=
2,
.,
=
=
size N do the following:
=
, I'=
of previous s.
pairs and letting
Since each drawing is independent,
ensure that the estimated Pvalue is within 3 units of the true one with (1  y)100%
confidence
(Agresti,
Wackerly,
and Boyett, 1979). In fact, for any Pvalue, if Z,/2
the (1  ^y/2)th
quantile of the standard normal distribution,
we can calculate approximate simulation
size N to
denotes
N Zy/2)
25
will be sufficient.
confidence,
For example, if one wants to estimate
Pvalue to within 8 = .01 with 99%
N > (2)( 0576))=
(2)(.01)~
16,589.44  17,000
4. Markov Chain Method
4.1 Construction
In order to define a Markov chain on the space Fo, corresponding
counts, we need to specify
the neighboring
the system
can jump by onestep transitions.
convenience,
we will, throughout
the paper, writefj even ifj > i but we will viewf; as j1 if
j> i.
Let (i1, i2) and (Ji,.J2)
be two integer
Define A = bl + 8i2 + 8'2JI + 8i2S2 and 8
function.
Obviously, 0 S A < 2. For two given integer pairs, there are three mutually
of Markov Chain
to the observed allelic
states for any f E Fo, i.e., other states to which
To do this, consider any f E Fo. For notational
pairs, with 1 < i, < i2 < m and 1 J
&i8l2,2, where bi is the usual Kronecker
il < 12 < m.
2
Page 6
Monte Carlo Test Qf HardyWeinberg
365
exclusive cases:
(i) A = 0
If fJj f22 # 0, we can subtract 1 from fXj, and from fh2,2 and add 1 to fh2 and to fA21,
respectively. We refer
to this process as type 0 donation switch or, in short, Doswitch
(with respect to f~j) and say f is D0switchable.
reception switch or Roswitch
1, and fil2 and f21 are each decreased by 1.
(ii) AX= 1
Iffij f2j2 $ 0, we can subtract 1 from fij, and from
respectively. We refer
to this process as type 1 donation switch or, in short, Diswitch
(with respect to fj) and say f is D1switchable.
reception switch or R lswitch
iffJj2f~jJ
case A = 0, but geometrically
in the triangular
genotype
is involved in the switch.)
(iii) A = 2
In this case ii = ji and i2 = j2: Two homozygous genotypes are involved. If
fil 22 # 0 we can subtract 1 fromfj and fromf2A2,
called a type 2 donation switch or D2switch
a type 2 reception
switch or R2switch
can be defined if fIj2 > 2.
Similarly, we can define a type 0
iffili2f2i ? 0; in this case, f I j and f2i2 are increased by
f2j2, and add 1 to fIj2 and to flj,
Similarly, we can define a type 1
this case is identical to the
array, it differs: One homozygous
# 0. (Algebraically,
and add 2 tof I2. This process is
(with respect to fijj). In similar fashion,
Regardless
or Rswitchable,
switchable
said to be nonswitchable
Note that after a switch is made (assuming switchable),
which has the same allele counts as that of f. That is, g E F(f). Further,
a switch is made on g so that a new table g' is obtained,
ratio P(g')/P(g) depends only on those cell entries of g that are changed. Table 1 shows
these ratios for different
switches.
By the Metropolis
algorithm
(Metropolis et al., 1953), we can construct
{f(t); t = 1, 2, . . .} of genotype counts that have the same allelic counts as the observed
sample, f, and an equilibrium distribution
Pr(f), the probablity
space for the Markov chain is Fo = F(f), a finite subset of the set of all triangular
counts {f(k): k = 1, 2, . . .4. Suppose a state
of type, if, for given integer
but not both, f is said to be partially switchable
and Rswitchable, we say f is fully switchable
(NS).
pairs (ij, i2) and (1l, 12), f is either Dswitchable
(PS). If f is both D
PS nor FS, f is
(FS). If f is neither
we obtain a new table, say g,
for any g E F(f), if
then g' E F(f) and the probability
a Markov chain
of f under HWP. The state
arrays of
f(k) & Fo is given. A new state f(l) is proposed
Table 1
different
Probability
/[(fl2
+ 1)(f2il
fli2f2il fillill + 1)(/f2i2 + 1)]
Ttyfljlf
2j2 /[(flj2 +
Probability ratiosfor
switches
ratio
+ 1)]
(y =
Type of switch
Do
Ro
DI
RI
D,
R2
Requirement
fflilf2p
5 0
filJ212ijl
filil tf22
fili2f2il
fil fi22 $ 0
fl2 2
.fililf22
5 0
$ 0
1)(f2il
+
1)]
kfl2fi2il /[(Y(flil + l(Ah
4f. .f2,2 /[(f.
~ ~ f~
+ 1)]
5 0
12 + 2)(f. j2 + 1)]
Ji(f;12  1)/[4(f1i + 1 )(f~i2
+ 1)]
Page 7
366
Biomnetrics,
June 1992
with probability
(Ripley, 1987):
Qkl. If f(l) ? FO, Qk1 = 0. The Markov chain transition probabilities are
Pr(f(k) * f(l)) min (1 Pr(f(k)))Qk1 (k
1))
Pr(f(k) unchanged)
= 1  I min( l Pr(f('))4
10k
Prff(k))Jk
4
For any two given integer pairs (il, i2) and (J, J2) with 1
1' < jr
If f(k) is NS, then we choose Qkl = 0 for 1 # k; if f(k) is PS and can be switched
then we choose Qkl = 0 for I # k, d and let Qkd = Qkk =
to, say f(d) and f(e), then we let Qkd = Qke =
The Markov chain we thus construct
from the fact that for any two tables in F(f), one can be obtained from another through
sequence of switches. (For proof, see Appendix.)
1
il < 12 < m and 1 <
f(k) is NS, PS, or FS.
to, say, f(d)
f1 is FS and can be switched
I and Qkj = 0 for]j d, e.
is finite and irreducible. The irreducibility
in, there are three situations
that we have discussed before:
if
comes
a
4.2 The Basic Formnulation
It is instructive
to rewrite
of the Method
(2) as
P=
E Pr(g) =
E I[Pr(g),Pr(f)]
g&rF
Pr(g) = E(h(g)),
(5)
where I is an indicator
Equation (5) says that P is exactly the expectation
Hence, for any function h(f) defined on F0, if we simulate this Markov chain for
t = 1, 2. . . N, the average
function, h(g) = I[pr(g)Pr(f)] and f is the observed table.
of the indicator
function
on space Fo.
N
F = I h(f(t))/N
t=l
(6)
is an estimate
For finite irreducible
F E(h(f)) with probability
In order for the estimate
chosen from the distribution
observed state), then the estimate
of low probability.
time so that the initial state is "forgotten."
Based on these facts, we have the following
of E(h(f)).
Markov chains, F is asymptotically
1 as N oo (Hastings, 1970).
to be unbiased, it is ideal to start the chain from a random state
Pr(f). If the chain is started from an arbitrary
will be biased, especially if the starting
One remedy is to start the chain from its initial state and run for a long
We refer to this process as "dememorization."
algorithm
normally distributed
and
state (e.g., the
state is in a region
to estimate P:
1. Let g = f; set counter K to 0 and cumulative
2. Dememnorization:
For prespecified
(i) Pick. Randomly pick two integer
and 1 < jl <1j2
(ii) Switch. Determine the switchability
calculated from (3):
If g is NS, the table remains unchanged
If g is PS, then switch g
same pattern unchanged with probability
c = Pr(g ')/Pr(g), if g is switched
ratio, p, to 1.
number of steps M, do the following:
pairs, (11, i) and (JI 12), with 1 < ii < 5r  m
< m.
of g and switch with transition
probability
and p' = p.
g', say, with probability
Pr(g g')
a nd remain the
Let p' = cp, where
1  Pr(g *g').
to g', or p' = p if g is unchanged.
Page 8
Monte Carlo Test of Hardy Weinberg
367
If g is FS, and g can be switched
Pr(g * g'), g * g" with probability Pr(g * g"), or remains unchanged with
probability 1  Pr(g * g')  Pr(g > g"). Let p' = cp, where c = Pr(g')/Pr(g),
Pr(g")/Pr(g), or 1, depending on whether
unchanged.
(iii) Update. Let p = p', and the new table be g if a switch is made.
3. Estimation. For prespecified
number of steps N do the following:
(i) Pick and switch,
as in step 2.
(ii) Count. If p' < 1, add I to K.
(iii) Update. Let p = p', and the new table be g if a switch is made.
4. The Monte Carlo test Pvalue is K/N.
to g' and g", say, then g * g' with probability
g is switched
to g', g", or remained
To prevent numerical overflow and underflow in computation, we suggest using
log c = log[Pr(g')/Pr(g)], and log p' = log p + log c.
Since the two neighboring states are correlated,
does not apply to this case. However, we can use a batching
estimate (Hastings, 1970; Ripley, 1987): Divide the observation into B batches of C
consecutive observations
each, and compute the mean of the ith batch by
the usual estimation
method to get an approximate
of statistical
variation
_
C
hi=
h((i  1)C + t)/C
and use
B
I (hi  h)2/[B(B  1)]
i=,1
_
S2 =
as an estimate of variance.
5. Numerical
In this section we provide some examples using the methods proposed in Sections 3 and 4.
The goodnessoffit tests were done using functions
computations were done on an IBM/RT workstation
The random number generator used was the runtime library rans, which produces
pseudorandom
numbers in the interval
(0, 1).
Examples
written
in S (Becker, 1988). All the
which uses BSD4.3 UNIX.
Example 1. We reanalyze the data in Figure 2 for which the exact Pvalue was reported
by Louis and Dempster (1987). It took, as they reported,
101.34 CPU seconds to come up
A
0
A,
3
1
A3
5
18
1
A4
3
7
5
2
Al
A2 A3 A
data from Figure 2. Genotype frequency Louis and Dempster (1987).
Page 9
368
Biometrics, June 1992
with the exact Pvalue of .01744 on an IBM 3081 computer using a complete enumeration
algorithm proposed by Louis and Dempster. The results of various goodnessoffit
along with the results of exact tests, are given in Table 2. Sample sizes of 1,700 and 17,000
were used for the conventional Monte Carlo method to ensure that the estimate is within
.02 with 90% confidence and within .01 with 99% confidence, respectively.
Note that none of the Pvalues calculated from goodnessoffit
true one, with the Pvalue given by Pearson's statistic with continuity correction .5 being
10 times as large as that calculated via the likelihood ratio statistic. Note also that in this
example the Pearson statistic with a continuity correction of .5 yields the most conservative
result.
tests,
tests is very close to the
Example 2. We analyze the simulated data that are presented in Section 1. The results of
goodnessoffit and exact tests are listed in Table 3. It is interesting
statistics employed could lead to completely different
from Pearson's statistics, with and without continuity corrections, are erroneously small,
with x2 being the most extreme. In retrospect, this is not surprising. For multiple alleles,
when all the allele frequencies are low and some extremely low (<.05, say), the expected
values can be much smaller than .5 or .25, resulting in erratically inflated values of the x2,
x.5, or x25 statistics.
to note that the different
conclusions. The Pvalues calculated
Table 2
Results of goodnessoffit
statistic;
x2, Pearson's statistic;
statistic with continuity
C is the size of each batch. For the Markov chain method,
The CPU time is in seconds (on an IBMIRT, unless otherwise
Statistic/Method
F2
G 2
x 2
X25
X225
Complete enumeration
Monte Carlo (B = 10, C = 170)
Monte Carlo (B = 100, C = 170)
Markov chain (B = 20, C = 1,000)
Markov chain (B = 20, C = 10,000)
and exact tests. F2 is the Freeman Tukey statistic;
X9, Pearson's statistic
correction
of .25 as suggested
G , the likelihood
correction
of.5; X25. Pearson's
by Emigh (1980). B is the number
the dememorization
specified).
Pvalue
S.E.
16.2761 .01235
17.1828 .008634
14.6270 .02337
11.0156 .08789
12.5852 .05012
.01744
.01706 .003557
.01724 .000954
.01705 .003617
.01727 .001404
ratio
with continuity
of batches,
period is 1,000 steps.
Value CPU time
101.34 (on IBM 3081)
19.4
193.5
17.2
165.2
Table 3
Results of goodnessoffit
and exact tests for simulated 8allele data. The dememorization
1,000 steps long for Markov chain method.
Statistic/Method
Value
14.7601
25.9748
51.9302
71.5300
39.4041
Monte Carlo (B = 10, C = 170)
Monte Carlo (B = 100, C = 170)
Markov chain (B =40, C =5,000)
.2186
Markov chain (B = 40, C = 10,000)
.2167
period is
Pvalue
.9809
.5744
.003908
1.1325 x0
.07464
.2182
.218 1
S.E.
CPU time
F2
G2
x2
x25


X225
.008058
.003242
.01 141
.007824
14.3
142.9
119.4
238.9
Page 10
Monte Carlo Test of Hardy Weinberg
369
Example 3. The Rhesus data shown in Figure 3 were reconstructed
and Bodmer (1971, pp. 224228), conditioning
estimated
allele frequencies.
For convenience,
in Table 4. Since the total sample size is extremely
conventional Monte Carlo method is not appropriate
offit
and exact tests are shown in Table 5. Again, the Pvalues calculated from x2 with
continuity
corrections are erroneously
small. It should be noted that, even for this large
total sample size, employment
of different
goodnessoffit
completely
different conclusions.
from CavalliSforza
counts and
Rhesus notations are given
large (n = 8,297), it is clear that the
in this case. The results of goodness
on the reported phenotypic
the alternative
test statistics
could lead to
Al
1,236
A,
120 3
A3
18 0
0
A4
982 55
7
249
A5
32
1
0
12
0
A6 2,582 132 20 1,162 29 1,312
A7
6
0
0 4
0
4
0
A8
2
0
0
0
0 0 0
0
A9 115
5
2
53
1
149
0
0
4
Avi A,
A3
A4
A5
A6
A7
A8
A9
Figure 3. Genotype frequency
data at Rhesus locus (CavalliSforza
and Bodmer, 1971).
Table 4
Alleles and haplotv'pes at Rhesus locits
Allele
Haplotype
A,
cde
,4,
cDe
43
cdE
A4
cDE
A5
Cde
A6
CDe
,47
CDE
AS
C"de
A9
C"De
Allele
r
Ro
r"
R,
r/
R
R
ret
R'
Page 11
370
Biometrics, June 1992
Table 5
Rhesus data. The dememorization
chain method is 1,000.
Value
Pvalue
21.8925
25.3359
23.0401
2,370.6736
<.0001
604.2268
<.0001
Results of goodnessq fit and exact tests./6r
periodfor
Markov
Statistic/Method
S.E. CPU time
F2
G2
x2
X.s
X~s
Markov chain (B = 100, C = 1,000)
Markov chain (B = 100, C = 5,000)
.9691
.9078
.9536





.7187
.6955
.02777
.01666
68.1
337.2
6. Discussion
Our purpose in giving examples in Section 5 is twofold:
the exact test and to demonstrate
our intention
to replace largesample
age the use of the exact test whenever
or simply when the adequacy of applying
The two proposed methods are computationally
compact programs.
The conventional
sample size of the simulation
error is within some range with, say, 99% confidence,
contrast, the sample size of the simulation necessary
Markov chain method increases with the size of the table. However, the Markov chain
method has the advantage that it does not require the HWP probability
generated
table (nor even of the observed one) and that the time spent on each switch is
virtually independent of the size of the table. Hence it can be used on any occasion, though
it is most useful when the table is large and sparse. It is faster
Carlo method when the sample size is moderate or large. For the conventional
Monte Carlo, the time spent on generating
a new table and on computing
probability
is proportional to the sample size. It is insensitive
Thus the conventional
Monte Carlo method is most suitable for data with a large number
of alleles but a small sample size.
For the conventional Monte Carlo method, a simulation size of 17,000 is usually sufficient
when the true Pvalue is well above or below the prespecified
Section 3). For both methods, we suggest using the batch estimate of standard error to
gauge the variability
of the estimate. Greater accuracy and reliability
at extra computing
cost.
For the Markov chain method, there is no simple way to determine
dememorization
period should be. Basically, if the sample size or the number of alleles is
large, one should use a longer period because there are more tables with the same margins
as that of the observed table. Ideally, the longer the period is, the better the result will be,
but an excessively
long dememorization
period may mean a lot of wasted computing
In most cases, 1,000 steps seems to suffice,
but larger problems
period.
It should be pointed out that if a population does exhibit HWP it should not be taken as
evidence that the conditions of the law are being satisfied
Hernatndez
and Weir, 1989). Several of the assumptions
may be violated simultaneously in such a way that their effects
to illustrate
of the method proposed here. It is not
goodnessoffit
tests for testing
the sample size is small and/or the table in sparse,
asymptotic
results is in doubt.
simple and can be implemented
Monte Carlo method has the advantage that the
can be determined
in advance to ensure that the estimation
regardless
to achieve desired accuracy for the
the desirability
of using
the practicality
HWP, but we encour
by very
of the size of the table. In
of each newly
than the conventional
Monte
the corresponding
to the number of alleles.
significance
level (see
are always available
how long the
time.
will definitely
need a longer
in that population (Li, 1988;
of HardyWeinberg
cancel each other.
equilibrium
Page 12
Monte Carlo Test qf Hardy Weinberg
371
ACKNOWLEDGEMENTS
in part by NIH Grant NHLBI HL3 0086 and NSF Grant BSR
8619760. The authors are grateful
to Joe Felsenstein
Carlo algorithm,
Ellen Wijsman for helpful discussions,
expert knowledge
in C and LaTeX. The authors also thank the two anonymous referees
for their useful comments.
The distribution of the computer
Grant HG00209.
RfSUMf
La loi de HardyWeinberg
joue un r6le important
dans le domaine de la genetique
et sert souvent de base pour l'inference
g&n&tique. Compte tenu de son importance,
beaucoup d'attention aux tests des proportions de HardyWeinberg
d'annees. On sait depuis longtemps
que les tests d'ajustement
resultats erron&s quand la taille de l'&chantillon
et/ou les fr&quences
algorithme
d'&num&ration
complete pour un test exact a &te propose, mais on ne peut pas l'utiliser
pour des loci ayant plus que quelques all&les a cause du volume de calcul. Nous proposons deux
algorithmes pour estimer le niveau de signification
facilement
applicables a des loci avec des all&les multiples.
et de calcul rapide. On compare l'efficacite
et les merites des deux algorithmes.
recommendations. On donne des exemples numeriques
This work was supported
for suggesting
and Charlie Geyer for sharing
the conventional
Monte
his
program
is supported
by NIH
des populations
on a consacre
dizaines
peuvent conduire a des
genotypiques sont petites. Un
(HWP) ces derni&res
asymptotique
pour un test de HWP. Les algorithmes
Les deux sont remarquablement
sont
simples
On donne des
des algorithmes.
pour illustrer
la praticabilit&
REFERENCES
J. M. (1979). Exact conditional
levels. Psychometrika
J. M., and Wilks, A. R. (1988). The New S Language: A Programming
Data Analysis
and Graphics.
Belmont,
California:
Besag, J. and Clifford,
P. (1989). Generalized Monte Carlo significance
633642.
Binder, K. and Heermann, D. W. (1988). Monte Carlo Methods in Statistical Phyvsics.
SpringerVerlag.
Botstein,
D., White, R. L., Skolick, M., and Davis, R. W. (1980). Construction
map in man using restriction
fragment length polymorphism.
Genetics
32, 31433 1.
CavalliSforza,
L. L. and Bodmer, W. F. (1971). The Genetics
W. H. Freeman.
Chapco, W. (1976). An exact test of the HardyWeinberg
Crow, J. E. (1988). Eighty
years ago: The beginnings
Elston, R. C. and Forthofer,
R. (1977). Testing for HardyWeinberg
Biometrics
33, 536542.
Emigh, T. H. (1980). A comparison of tests for HardyWeinberg
627642.
Emigh, T. H. and Kempthorne,
0. (1975). A note on goodnessoffit
Weinberg structure. American
Journal of Hutiman
Haldane, J. B. S. (1954). An exact test for randomness
Hastings,
W. K. (1 70). Monte Carlo sampling
methods
Biometrika
57, 97109.
Herndndez,
J. L. and Weir, B. S. (1989). A disequilibrium
testing.
Biometrics
45, 5370.
Levene, H. (1949). On a matching
problem arising in genetics.
9194.
Li, C. C. (1955). Population Genetics.
Chicago: University
Li, C. C. (1988). Pseudorandom
mating populations.
HardyWeinberg law. Genetics 119, 731737.
Louis, E. J. and Dempster, E. R. (1987). An exact test for HardyWeinberg
Biometrics
43, 805811.
Metropolis,
N., Rosenbluth,
A. W., Rosenbluth, M. N., Teller, A. H., and Teller, E. (1953). Equations
of state calculations
by fast computing
machines.
Agresti,
Approximation
Becker, R. A., Chambers,
Environment/fr
A., Wackerly,
D., and Boyett,
of attained significance
tests for crossclassification:
44, 7583.
Wadsworth
tests. Biometrika 76,
and Brooks/Cole.
Berlin:
of a genetic linkage
American Journal of Human
of Hutman
Populations.
San Francisco:
law. Biometrics
of population
32, 183189.
genetics.
Genetics
equilibrium
119, 473476.
in small samples.
equilibrium.
Biometrics
36,
of a population to Hardy
27, 778783.
of mating.
Journal of Genetics
using Markov chains and their applications.
Genetics
52, 631635.
coefficient
approach to HardyWeinberg
Annals of Mathematical Statistics
20,
of Chicago Press.
In celebration
of the 80th anniversary of the
and multiple alleles.
Journal
of Chemical Physics 21, 10871092.
Page 13
372
Biometrics, June 1992
Nakamura,
E., Hoff, M., Kumlin, E., and White, R. (1987). Variable number of tandem repeat (VNTR)
markers for human gene mapping.
Science 2351, 16161622.
Ripley, B. D. (1 987). Stochastic
Simulation. New York: Wiley.
Smith, C. A. B. (1986). Chisquared tests with small numbers. Annals of Human Genetics 50,
163167.
Y., Leppert, M., O'Connell, P., Wolff,
R., Hom, T., Culver, M., Martin, C., Fujimoto,
Received February
1990; revised October 1990; accepted February 199 1.
APPENDIX
Proof of Irreducibility
of the Markov Chain of Section 4
We prove the result by induction.
For m = 2, the result is trivial. Now we assume it is true for m' < m. Consider the case of m
alleles. Suppose f, g E F. For notational
convenience,
and its count. We first
pool the alleles Al and A2 together,
two tables of order m  1, say, f' and g', and, by assumption,
sequence of switches.
These switches
can obviously
3rd, 4th, ..., Imth columns of f and g are exactly the same. The only difference
columns. We now prove that there exist some switches
columns and after these switches
the two tables will be exactly the same.
Note that, because of marginal
constraints,
f + f2 = gjI + gj2 (j = 3, 4, . . ., m). Without loss of
generality, we can assume ,,I > gn, I since every switch is reversible.
gZn2
we can also assume that g22 ?.fIL; otherwise
i = 2,12 = m andj, = 1, j2 = 2 and make min(f22
 g22, ki,7)
eitherfni
or g22 = f22 or both. Now, since
we will make no distinction
as if they were the same. Then we have
g' can be obtained from f' through
be regarded
as made on f so that, after switch,
between the cell
a
the
is the first two
that do not touch the 3rd, 4th, . . ., and mth
Now, suppose km1
=fn
we can choose

gini
=
 A,2 > 0. Without loss of generality,
Roswitches so that, after these switches,
= g,,,1
f21 + f22 +
+ f1,2
=/f2 f22
fn72
= (g2  f22  gi2) + k,*7
> (g2  g22  gi2) + k,,, (as g22 ; f22)
k I
(all with ji = 1,
f = gin and
we can always find
these switches
second columns.
By the same token, we can successively
2 = gi2 (i = m  1, m  2, .. ., 4, 3), without touching either 3rd, 4th, . . ., mth columns or cells in
rows below the ith. After the case i = 3, the only difference
marginal
constraints,
2,f I + f2i = 2g, I + g21, 2 fi2 + f^I = 2g22 + g2 . This is the case of m = 2. We
can find I fi  g, I D2switches
(ifJL
f
g,,) or Rswitches
andf22 = g22 after these switches.
Thus we complete our proof.
kin Roswitches
are performed,
J2 = 2, i, = m, but with varying
f?2 = g,72. Note that the switch involves only the first
i,), so that, after
and
find ki switches
so that, after these switches,
fJI = gi and
is f, Lf2, and f2. Again, due to the
(iff1
I gl ) so that1 = g1 , f2l = 92l,