WORKED EXAMPLE · CATEGORICAL ASSOCIATION
Chi-Square Worked Example: Program Group and Response Category
Build a 2×3 count table from participant-level categories, calculate expected counts and degrees of freedom, interpret the overall chi-square result, and reproduce it in BioTabular.
Published by BioTabularLast reviewed: November 4, 2026
This example uses synthetic data from 60 independent participants. Each participant belongs to either a Standard or Coached program and is classified once at follow-up as Improved, Unchanged, or Worsened relative to a prespecified baseline criterion. The question is whether program group and response category are associated in the population represented by these participants. This is an observational teaching scenario; it supplies no randomized assignment or adjustment for baseline differences.
Define the units, categories, and question
- Observational unit
- One independently sampled participant, appearing in one table cell.
- Row variable
- Program group: Standard or Coached.
- Column variable
- Follow-up response: Improved, Unchanged, or Worsened.
- Null hypothesis
- The response-category distribution is independent of program group.
- Starting method
- Pearson chi-square test of independence for the 2×3 table.
The response labels are mutually exclusive and exhaustive for the defined follow-up window. Although response is derived by comparison with each participant’s baseline status, the analysis file contains one final category per person. It is therefore a table of independent participant rows, not a paired before-and-after contingency analysis. If participants were matched, repeatedly observed, or clustered by site, this ordinary test would not account for that dependence.
Inspect the complete synthetic data
The downloadable CSV has one row per participant. The table below displays those same 60 rows, so the category counts can be checked directly. IDs are labels, not values used in the chi-square calculation.
| Participant | Program group | Response category |
|---|---|---|
| S01 | Standard | Improved |
| S02 | Standard | Improved |
| S03 | Standard | Improved |
| S04 | Standard | Improved |
| S05 | Standard | Improved |
| S06 | Standard | Improved |
| S07 | Standard | Unchanged |
| S08 | Standard | Unchanged |
| S09 | Standard | Unchanged |
| S10 | Standard | Unchanged |
| S11 | Standard | Unchanged |
| S12 | Standard | Unchanged |
| S13 | Standard | Unchanged |
| S14 | Standard | Unchanged |
| S15 | Standard | Unchanged |
| S16 | Standard | Unchanged |
| S17 | Standard | Unchanged |
| S18 | Standard | Unchanged |
| S19 | Standard | Worsened |
| S20 | Standard | Worsened |
| S21 | Standard | Worsened |
| S22 | Standard | Worsened |
| S23 | Standard | Worsened |
| S24 | Standard | Worsened |
| S25 | Standard | Worsened |
| S26 | Standard | Worsened |
| S27 | Standard | Worsened |
| S28 | Standard | Worsened |
| S29 | Standard | Worsened |
| S30 | Standard | Worsened |
| C01 | Coached | Improved |
| C02 | Coached | Improved |
| C03 | Coached | Improved |
| C04 | Coached | Improved |
| C05 | Coached | Improved |
| C06 | Coached | Improved |
| C07 | Coached | Improved |
| C08 | Coached | Improved |
| C09 | Coached | Improved |
| C10 | Coached | Improved |
| C11 | Coached | Improved |
| C12 | Coached | Improved |
| C13 | Coached | Improved |
| C14 | Coached | Improved |
| C15 | Coached | Improved |
| C16 | Coached | Improved |
| C17 | Coached | Improved |
| C18 | Coached | Improved |
| C19 | Coached | Unchanged |
| C20 | Coached | Unchanged |
| C21 | Coached | Unchanged |
| C22 | Coached | Unchanged |
| C23 | Coached | Unchanged |
| C24 | Coached | Unchanged |
| C25 | Coached | Unchanged |
| C26 | Coached | Unchanged |
| C27 | Coached | Worsened |
| C28 | Coached | Worsened |
| C29 | Coached | Worsened |
| C30 | Coached | Worsened |
Build the observed count table
| Program group | Improved | Unchanged | Worsened | Total |
|---|---|---|---|---|
| Standard | 6 | 12 | 12 | 30 |
| Coached | 18 | 8 | 4 | 30 |
| Total | 24 | 20 | 16 | 60 |
Among Standard participants, 6/30 (20%) improved, 12/30 (40%) were unchanged, and 12/30 (40%) worsened. Among Coached participants, those within-group percentages are 18/30 (60%), 8/30 (26.7%), and 4/30 (13.3%). Percentages help describe the pattern, while the test uses the underlying counts.
Calculate expected counts under independence
If group and response were independent, the expected count for a cell would be its row total multiplied by its column total, divided by the overall total. For Standard–Improved, that is (30 × 24) ÷ 60 = 12. The other expected counts are calculated in the same way:
| Program group | Improved | Unchanged | Worsened |
|---|---|---|---|
| Standard | 12 | 10 | 8 |
| Coached | 12 | 10 | 8 |
All six expected counts are at least 8; none is below 5. That supports use of the ordinary chi-square approximation here. These are hypothetical counts under the null model, not a second set of observed participants. Expected-count guidance is a diagnostic for the approximation, not a guarantee that the sampling or classification process is unbiased.
From cell discrepancies to the overall statistic
Each cell contributes (observed − expected)² ÷ expected. For Standard–Improved the contribution is (6 − 12)² ÷ 12 = 3. For Coached–Improved it is also 3. The Unchanged cells contribute 0.4 each, and the Worsened cells contribute 2 each. Summing the six contributions gives χ² = 3 + 0.4 + 2 + 3 + 0.4 + 2 = 10.8.
The degrees of freedom for an r×c independence table are (r − 1)(c − 1). With two groups and three response categories, (2 − 1)(3 − 1) = 2. The 2 represents independent ways the table can vary after the margins are fixed; it is not the number of outcomes, a sample size, or an effect size. BioTabular applies no continuity correction to this 2×3 table; its optional correction is specific to 2×2 tables.
Read the result
- Complete participant rows
- 60; omitted 0
- Table dimensions
- 2 groups × 3 response categories
- Expected cells below 5
- 0 of 6
- Pearson chi-square
- χ²(2) = 10.8
- Association p-value
- 0.004517
- Descriptive effect size
- Cramér’s V = 0.424
At α = .05, the table provides evidence against independence between program group and response category. The observed proportions show the direction of the pattern, but the omnibus p-value alone does not say that all three response categories differ independently. Cramér’s V is calculated here as √(10.8 ÷ [60 × min(2 − 1, 3 − 1)]) = 0.424. It summarizes association strength without a direction; BioTabular does not currently calculate this effect size in the Workspace output.
The test does not estimate an adjusted program effect, a risk ratio, or a causal contrast. If the question is a specific Improved-versus-not-Improved comparison, define that binary target in advance and estimate the relevant effect and uncertainty using a suitable method. Do not collapse categories after seeing this result solely to obtain a preferred p-value.
Reproduce the result in BioTabular
- Download the synthetic CSV and open the categorical-association calculator.
- Import the file. Mark
Participant_IDas an identifier, and keepProgram_GroupandResponse_Categorycategorical. - Set the group order to Standard, then Coached, and the response order to Improved, Unchanged, then Worsened. Confirm the column types and category order.
- Select
Program_Groupas the first categorical variable andResponse_Categoryas the second. Keep α = .05 and run the analysis. - Confirm 60 complete cases, the observed 2×3 table, χ²(2) = 10.800, p = .005 after display rounding, and zero expected cells below 5. Use Plot Studio to view grouped counts or within-group percentages.
Interpret and report responsibly
“Among 60 independent participants (30 per program group), response-category distributions differed between Standard and Coached programs (Pearson χ²(2) = 10.80, p = .0045). Improved responses occurred in 6/30 (20%) Standard and 18/30 (60%) Coached participants; Worsened responses occurred in 12/30 (40%) and 4/30 (13.3%), respectively. All expected cell counts were at least 8. The descriptive Cramér’s V was .424.”
Report all observed counts and denominators alongside the test result. State how response categories were defined, how participants entered each program, and whether the comparison was planned. Any post-hoc cell or pairwise follow-ups need a stated method and consideration of multiple testing. The observational design leaves open baseline differences, selection, and other explanations for the association.
Common mistakes and limits
- Testing percentages alone without the underlying participant counts.
- Checking only observed counts while ignoring expected counts under independence.
- Confusing the 2 degrees of freedom with the three response categories or with sample size.
- Claiming every cell differs from its counterpart because the omnibus test is significant.
- Using a 2×2 continuity correction for this 2×3 table.
- Treating repeated visits, matched people, or clusters as independent observations.
- Reading an association as evidence that the program caused a change.
The data are synthetic and balanced by design. Real response categories can be ambiguous, rare, missing, or measured at different times. A sparse larger table may need an exact or simulation-based method that BioTabular does not currently provide; a complex design may require a regression or clustered analysis. Specify categories and primary comparisons before seeing the results.
Related resources
Compare the adequate expected counts here with the Fisher’s exact sparse 2×2 worked example. Read Chi-square vs. Fisher’s Exact Test for the broader method choice, or Which Statistical Test Should I Use? for other designs.
References and further reading
- NIST: Chi-square independence test
- R documentation: Pearson’s chi-square test for count data
- NIST/SEMATECH e-Handbook of Statistical Methods
- American Statistical Association statement on statistical significance and p-values
BioTabular’s editorial approach and scope explain how these educational resources are prepared and what they do not replace.