Why Calculate an Exact Goodness-of-Fit P-Value?
A Pearson goodness-of-fit test compares observed category counts with the counts expected under a null probability model. When the model’s expected counts are small, the chi-square approximation used to obtain a p-value may be unreliable. An exact multinomial test takes a different route: it considers the possible count vectors for the fixed sample size and adds their probabilities under the null model.
“Exact” means that the calculation uses the specified null probability model directly, rather than approximating the distribution of the test statistic with a chi-square distribution. It does not mean that every aspect of the analysis is automatically correct. The categories, sampling assumptions, null probabilities, and rule for deciding which outcomes count as at least as extreme must all be specified.
The Model and the Exact P-Value
Suppose \(n\) independent observations each fall into exactly one of \(k\) categories. Under the null hypothesis, the probability of category \(i\) is a specified value \(p_i\), where \(p_i>0\) and \(\sum_{i=1}^{k}p_i=1\). The total sample size \(n\) is fixed. Write the observed count vector as \((O_1,\ldots,O_k)\), with \(\sum_{i=1}^{k}O_i=n\).
For a Pearson goodness-of-fit test, the expected count in category \(i\) is \(E_i=np_i\), and a possible vector’s Pearson statistic is
The exact p-value for the observed vector is the sum of the null probabilities of all possible vectors whose statistic is at least as large as the observed statistic. “At least as large” includes ties.
This procedure assumes that the observations are independent and follow the same category probabilities under the null, that the category probabilities are fixed and correctly specified, and that the sample size is fixed. It also assumes each observation is counted once in exactly one category. The formula is exact for this model; it cannot repair dependence between observations or an unsuitable null model.
Worked Example: Enumerating a Three-Category Tail
Worked Example: Enumerating a Three-Category Tail
Suppose four independent observations fall into categories A, B, and C. Under the null hypothesis, their probabilities are \(0.50\), \(0.25\), and \(0.25\). The observed counts are \((4,0,0)\). Calculate the exact p-value using the Pearson statistic.
The model has fixed \(n=4\), with the same probabilities for each independent observation; all three probabilities are positive and sum to 1. The expected counts are
For the observed vector, the statistic is
There are \(\binom{6}{2}=15\) possible nonnegative count vectors summing to 4. Enumerating them and retaining those with \(T\ge 4\) gives the following eight vectors. Their probabilities use the multinomial formula; for example, the probability of \((1,3,0)\) is \(4!/(1!3!0!)(0.50)(0.25)^3=1/32\).
| Count vector | Pearson statistic \(T\) | Null probability |
|---|---|---|
| (4, 0, 0) | 4 | 1/16 |
| (1, 3, 0) | 5.5 | 1/32 |
| (1, 0, 3) | 5.5 | 1/32 |
| (0, 0, 4) | 12 | 1/256 |
| (0, 1, 3) | 6 | 4/256 |
| (0, 2, 2) | 4 | 6/256 |
| (0, 3, 1) | 6 | 4/256 |
| (0, 4, 0) | 12 | 1/256 |
For instance, the tied vector \((0,2,2)\) has statistic \(2+(2-1)^2+(2-1)^2=4\). Its probability is \(4!/(0!2!2!)(0.25)^4=6/256\). It must be included because its statistic equals, rather than exceeds, the observed statistic.
Adding the probabilities of all eight tail vectors gives
Thus, under the stated null model, 18.75% of samples of four observations have a Pearson statistic at least as large as the one observed. At significance level \(\alpha=0.05\), this p-value does not provide sufficient evidence to reject the null model.
Why the Sum Is a Valid Tail Probability
The possible count vectors form a finite set: every coordinate is a nonnegative integer and their sum is \(n\). Under the null model, the multinomial probabilities of all these vectors sum to 1. This follows from the multinomial theorem:
Consequently, summing the probabilities of the vectors meeting the stated statistic threshold gives their probability under the null model. The procedure also explains why an exact test can be conservative at a chosen significance level: because the possible outcomes have discrete probabilities, attainable p-values may jump over \(\alpha\). The probability of rejecting at level \(\alpha\) is therefore no greater than \(\alpha\) when the model holds, but it need not equal \(\alpha\).
To see this, group the possible vectors by their statistic values, starting with the largest. For a vector at a particular statistic level, its p-value is the total probability at that level and all larger levels. The rejection rule \(p_{\mathrm{exact}}\le\alpha\) includes only upper groups whose cumulative probability is at most \(\alpha\). Thus the total null probability of rejection cannot exceed \(\alpha\). Tied vectors belong to the same statistic level and must be treated together under this rule.
Worked Example: A Two-Category Exact Test
Worked Example: A Two-Category Exact Test
In a hypothetical setting, six independent observations are classified into categories A and B. The null probabilities are \(0.50\) and \(0.50\), and the observed counts are \((6,0)\). Use the Pearson statistic to find the exact p-value.
The fixed sample size is \(n=6\), and the expected counts are \(E_A=E_B=3\). The observed statistic is
Let \(x\) be the count in A, so the possible vectors are \((x,6-x)\) for \(x=0,1,\ldots,6\). Their statistics and probabilities are:
| \(x\) | Count vector | \(T\) | Null probability |
|---|---|---|---|
| 0 | (0, 6) | 6 | 1/64 |
| 1 | (1, 5) | 8/3 | 6/64 |
| 2 | (2, 4) | 2/3 | 15/64 |
| 3 | (3, 3) | 0 | 20/64 |
| 4 | (4, 2) | 2/3 | 15/64 |
| 5 | (5, 1) | 8/3 | 6/64 |
| 6 | (6, 0) | 6 | 1/64 |
For example, the probability of \(x=1\) is \(\binom{6}{1}(0.5)^1(0.5)^5=6/64\). Only the two endpoint vectors have \(T\ge6\), so
At \(\alpha=0.05\), the result is statistically significant under this specified test. The exact p-value is the probability, assuming the null model, of a Pearson statistic at least 6—not the probability that the null hypothesis is true.
Worked Example: An Unequal Null Probability
Worked Example: An Unequal Null Probability
Suppose five independent observations fall into A or B, with null probabilities \(P(A)=0.20\) and \(P(B)=0.80\). The observed counts are \((0,5)\). Calculate the exact Pearson p-value.
The expected counts are \(E_A=5(0.20)=1\) and \(E_B=5(0.80)=4\). The observed statistic is
Let \(x\) denote the count in A. The statistic for vector \((x,5-x)\) simplifies to
The following table lists every possible value of \(x\), so the tail can be identified directly. Each probability is \(\binom{5}{x}(0.20)^x(0.80)^{5-x}\).
| \(x\) | \(T\) | Null probability | Included in tail? |
|---|---|---|---|
| 0 | 1.25 | 0.32768 | Yes |
| 1 | 0 | 0.40960 | No |
| 2 | 1.25 | 0.20480 | Yes |
| 3 | 5 | 0.05120 | Yes |
| 4 | 11.25 | 0.00640 | Yes |
| 5 | 20 | 0.00032 | Yes |
The observed statistic is 1.25, so both \(x=0\) and \(x=2\) are included: they tie at the threshold. Summing all included probabilities gives
This is not the probability of observing a count of zero or fewer in A. The p-value is defined by the Pearson statistic, and an outcome with two observations in A is just as extreme by that statistic as the observed outcome.
Enumeration, Interpretation, and Common Pitfalls
For a small sample and a modest number of categories, the possible count vectors can be listed by assigning nonnegative integer counts that sum to \(n\). For each vector, calculate the statistic and its null probability; then sum probabilities for all vectors at or beyond the observed statistic. A probability table, careful hand enumeration, or software can perform the arithmetic, but the definition of the tail should remain explicit.
In larger problems, enumerating every vector may require substantial computation. This tutorial’s method is the exact finite enumeration procedure; simulation-based approaches are a separate method. Whatever computational tool is used, verify that the listed or selected outcomes satisfy the fixed-total constraint and that the tail includes every tie.
- Omitting a tie. A vector with a statistic equal to the observed statistic belongs in the tail. Leaving it out understates the p-value.
- Summing only the probability of the observed vector. The p-value sums probabilities over every count vector meeting the extremeness rule, not just the observed vector.
- Using a one-sided count tail automatically. In more than two categories, “larger count in one category” is not a general definition of extremeness. Use the stated statistic and its threshold.
- Calling the p-value the probability that the null is true. It is a probability of data outcomes calculated assuming the null model, not a probability of the hypothesis.
- Assuming exact means assumption-free. The calculation is exact only under the specified probability model and sampling assumptions.
Check Your Understanding
Use the definition of the exact p-value and the stated statistic to answer these questions.
- Why must the counts in a possible vector sum to the fixed sample size \(n\)?
- For a Pearson exact test, should a vector with statistic equal to the observed statistic be included in the p-value sum? Explain.
- Under a null model with three category probabilities \(0.2\), \(0.3\), and \(0.5\), what are the expected counts when \(n=10\)?
- What assumptions make the multinomial probability formula appropriate for a goodness-of-fit calculation?
- Explain why an exact p-value need not be equal to the significance level when the null model is true.