# How to calculate df in the chi-square test of Hardy-Weinberg equilibrium? [closed]

We often use df=1 in Hardy-Weinberg equilibrium when there are only two alleles. Some people say that it's because we've used the frequency of two alleles when calculating the expectated values, while others may give different explanations.

The website for the second explanation:https://www.mun.ca/biology/scarr/4250_Chi-Square_HWP.html
The principle is that, if you know you looked at n experimental results that could have fallen into any of three categories a b c, the value of the first category a can be anything (up to n), and the value of the second category b can be anything up to (n-a). Having determined a and b, the third value is now pre-determined: c = (n - a - b). So, only two of the three values are free to vary. For diploid genotypic data with two alleles A & G and three genotypes AA, AG, & GG, this would suggest df = 2 in the observed data. However, given f(A), the expected frequencies for all three genotypes are automatically determined, thus there is only one degree of freedom.

This affects how to calculate df when there are more than 2 alleles. The first answer is df=3, which is from the Hartl's textbook, but unfortunately it's in the afterclass questions, and it doesn't have an answer, so I don't know why. The second one gives df=2. I found another article (in a chinese website) which says that df=m*(m-1)/2 (m is the number of alleles). Which one is right, or which one is commonly used?

Now I believe that my question is solved, so I won't open this question.

• It would be helpful to have links to the sources that you have found so far, particularly so for the long quote.
– kmm
Dec 29, 2023 at 1:33
• You'll need to at least explain what the first method is and how it results in df=3. Dec 29, 2023 at 15:59
• After the latest edits I'm still not clear what the first explanation leading to df=3 is. If the explanation is that for 2 alleles there is 1 "free" parameter to vary because if you know p or q you can derive the other as 1-p or 1-q, therefore 1 DF, then for 3 alleles you would still get 2 DF: if p+q+m = 1, you have 2 DF because you only need two of the three to calculate the third. That's the same as the second explanation, and really it's the same explanation, too. Where did you get 3 DF from for 3 alleles? You must explain this even if the original is in Chinese. Jan 2 at 14:56
• (closing for now, because even as a good question, without this piece of clarity it would be inappropriate for someone to answer your question) Jan 2 at 14:56
• @BryanKrause I agree with you on df=2. 3 DF is from the afterclass question in Hartl's textbook. It just asks "In the situation with 3 alleles, the df should be 3. Explain why." And it's with an odd number, while the textbook only gives answers for questions with even number, so I really don't know the reason. Maybe it's just wrong. Jan 4 at 10:23