Statistics worked example
Chi Square Calculation Example: Expected Counts and Formula
A chi-square test compares observed categorical counts with counts expected under a null model. The calculation is transparent when every cell contribution is shown.
Answer first
For a contingency table, expected count equals row total times column total divided by N
Calculate each expected count as E = (row total × column total) / grand total. Then sum (O – E)²/E across cells. For an r by c table, degrees of freedom are (r – 1)(c – 1).
The test evaluates association between categorical variables under the design and model. It does not show causation, identify a mechanism, or replace the observed counts and percentages.
A method you can reuse
Build expected counts before calculating chi-square
Use counts, not percentages, in the formula. The expected table preserves the observed row and column margins while representing independence.
Independence comes from the sampling design. Small expected counts can make the large-sample reference distribution unreliable. Exact or alternative methods may be needed.
Create the observed-count table
Define mutually exclusive categories and confirm every observational unit is counted appropriately.
Calculate row, column, and grand totals
Reconcile totals before any inferential calculation. A mismatch usually indicates data preparation error.
Calculate expected counts
Multiply the relevant row and column totals, then divide by N for each cell.
Calculate each cell contribution
Use (O – E)²/E and retain enough decimal precision to audit the total.
Interpret with percentages and effect size
Report counts, conditional percentages, chi-square, df, p-value, and Cramer’s V or another relevant magnitude measure.
Worked from start to finish
Chi square calculation example for workshop attendance
A fictional study records whether 100 students attended a workshop and whether they passed an assessment.
Pass Not pass Total
Workshop 36 14 50
No workshop 24 26 50
Total 60 40 100
Expected workshop-pass = 50 × 60 / 100 = 30
Expected workshop-not pass = 50 × 40 / 100 = 20
The second row has the same expected counts.
chi-square = (36-30)²/30 + (14-20)²/20 + (24-30)²/30 + (26-20)²/20
chi-square = 1.2 + 1.8 + 1.2 + 1.8 = 6.00
df = (2-1)(2-1) = 1
Cramer’s V = √[6 / (100 × 1)] = 0.245
The pass rate is 72 percent among workshop attendees and 48 percent among nonattendees. Those percentages make the direction visible.
Because attendance was not described as randomized, the association may reflect motivation, prior preparation, scheduling, or other differences. It does not prove the workshop caused the higher pass rate.
Cell-by-cell chi-square calculation table
Showing contributions makes it easy to identify which cells create the total statistic.
| Cell | Observed O | Expected E | (O – E)² / E |
|---|---|---|---|
| Workshop and pass | 36 | 30 | 1.20 |
| Workshop and not pass | 14 | 20 | 1.80 |
| No workshop and pass | 24 | 30 | 1.20 |
| No workshop and not pass | 26 | 20 | 1.80 |
For a goodness-of-fit test, expected counts come from specified category probabilities rather than row and column totals. The degrees of freedom can also change when parameters are estimated from the data.
Standardized residuals help locate cells that differ from expectation, but examining many cells creates multiple-comparison concerns. Plan interpretation instead of declaring every large residual a separate discovery.
What students report
Real student experiences, with context
These public comments are personal experiences, not universal outcomes. They are included because they show where students commonly get stuck and how the method above helps.
“the question you’re trying to answer is central”
Student discussion in r/statistics
Variable types matter, but the estimand and study design come first. The same columns can support different tests when the research question changes.
“Getting it isn’t the problem; over-interpreting it is.”
Student discussion in r/statistics
Software can calculate a p-value instantly. The harder work is checking the design, assumptions, multiplicity, effect size, uncertainty, and practical importance.
Failure-mode review
Common problems and how to repair them
Entering percentages instead of counts
The test statistic uses observed counts. Percentages should accompany the report for interpretation.
Treating repeated observations as independent
Matched pairs, repeated visits, or clustered data require methods that represent dependence.
Ignoring sparse expected cells
Review the expected table and use an appropriate exact, collapsed, or model-based approach when assumptions fail.
Interpreting association as causation
Explain the sampling and assignment design, confounding, and temporal order before making causal claims.
Before you submit or move on
A practical final check
- Categories are mutually exclusive and correctly coded.
- Observed totals reconcile.
- Expected counts are calculated from the right null model.
- Cell contributions sum to the reported statistic.
- Degrees of freedom are correct.
- Sparse counts and independence are assessed.
- Counts and conditional percentages are reported.
- Association strength and design limits are discussed.
Related tools and help
Questions students ask
Frequently asked questions
How do I calculate an expected count for chi-square?
Multiply the cell’s row total by its column total and divide by the grand total for a test of independence.
What is the chi-square test formula?
Sum (observed minus expected) squared divided by expected across all cells.
How do I find chi-square degrees of freedom?
For an r by c test of independence, df = (r – 1)(c – 1).
Can I use percentages in a chi-square calculation?
No. Use counts in the test. Report percentages alongside counts to explain the pattern.
What does Cramer’s V show?
It summarizes the magnitude of categorical association on a nonnegative scale, but it still needs context and uncertainty.
Sources and further reading
- American Statistical Association Statement on P-Values. Official principles for responsible p-value interpretation.
- NIST Engineering Statistics Handbook: Confidence Intervals. Primary government reference for confidence interval construction and interpretation.
Forum quotations are short excerpts from public discussions. They describe individual experiences and have not been independently verified. Factual guidance in this article is grounded in the primary and institutional sources listed above.
Reviewed by the Bright Writers Academic Support Team.
We create calculation guides, planning tools, and course support resources. Corrections can be sent to [email protected].

