36
Stata Technical Bulletin
STB-48
Hardy-Weinberg Equilibrium Test :
Pearson chi2 (1) = 1.956 Pr= 0.1620
likelihood-ratio chi2 (1) = 1.959 Pr= 0.1616
Exact significance prob = 0.1793
Example 2: multiallelic locus
Spencer et al. (1964) examined the distribution of the red cell acid phosphatase polymorphism in 178 randomly selected
individuals. They identified 3 alleles at this locus; A, B and C. We would like to test the null hypothesis that these data are
consistent with Hardy-Weinberg equilibrium. Their data has been entered into Stata. Here are the first ten observations:
. list in 1/10
alll all2
1. |
A |
A |
2. |
A |
B |
3. |
A |
C |
4. |
B |
B |
5. |
B |
C |
6. |
A |
B |
7. |
A |
B |
8. |
B |
B |
9. |
A |
A |
10. |
B |
B |
We now perform the test for Hardy-Weinberg equilibrium:
. genhw alll all2
Genotype |
I Observed |
Expected ( |
Disequilibrium Coefficient (D) |
— AA AC BB CC |
I 17 I 86 I 5 I 61 I 9 I 0 |
21.95 76.19 4.92 66.14 8.53 0.28 |
— -0.0275 -0.0002 -0.0013 |
— Total Allele |
I 178 I Observed |
178.00 Frequency |
— Std. Err. |
— A C |
I 125 I 217 I 14 .+----------- |
0.3511 0.6096 0.0393 |
0.0237 0.0242 0.0101 — |
Hardy-Weinberg Equilibrium Test :
Pearson chi2 (3) = 3.078 Pr= 0.3798
likelihood-ratio chi2 (3) = 3.407 Pr= 0.3330
Similar to the output in the biallelic case, genotype and allele frequency tables are produced. However, instead of only one
disequilibrium coefficient, in the multiallelic case, a disequilibrium coefficient is estimated for each heterozygous genotype.
For these data, we fail to reject the null hypothesis that the population is in Hardy-Weinberg equilibrium with respect to
this locus.
Saved results
genhw saves in r():
Scalars
r(chi2)
r(df)
r(chi2_p)
r(lr.chi2)
r(lr_p)
r (p_exact )
r(D)
Pearson’s chi squared
degrees of freedom
significance probability (Pearson)
likelihood-ratio chi squared
significance probability (LR)
exact significance probability (biallelic only)
disequilibrium coefficient (biallelic only)