Statistics & Data Analysis

Chi-square Tests

Run goodness-of-fit or contingency-table independence tests from counts, with expected counts, cell contributions, p-values and sparse-data warnings.

Question, try, then observe

Which counts depart from expectation?

Prespecify equal probabilities for three categories. Edit the observed counts; expectations recalculate with the total and each contribution updates.

01 · Make a predictionDoes one count differing from expectation guarantee significance?
CategoryObserved OExpected Eχ² contribution
205
200
205
Observed count scenario
Significance level α

Calculate each cell's contribution, then sum

χ²=(30−20)220+(20−20)220+(10−20)220≈10
  1. Here, expected counts equal total sample size times the null proportions. Small expected counts still limit the approximation.

Observed and expected counts

Lower-risk preference
O
30
E
20
Medium-risk preference
O
20
E
20
Higher-risk preference
O
10
E
20
Solid O: observed. Outlined E: expected. Proportions are prespecified, not fitted from these same counts with unchanged df.

χ² · reference distribution

df=2 · α=0.05 · p=0.0067

χ² · reference distributionDensity curve. Statistic 10, p 0.0067, alpha 0.05. Solid area is the observed tail; hatched area is the planned rejection region. Read exact critical values below.Density05.29810.6
Observed tail (solid)α rejection region (hatched)Statistic: dotted · Critical: dashed
Statistic: 10Critical value(s): 5.991The drawing truncates long tails. Probabilities use the complete distribution, not the displayed area.
χ²10df=2
p-value0.0067
Total observed count60

Reject H₀ at the selected α; assumptions and practical magnitude still matter.

This interaction demonstrates goodness-of-fit. The calculator also supports contingency-table independence. Both use counts, not percentages as sample sizes, and neither establishes causation.

What did you just see?

When each category expects 20 people, 20/20/20 matches the model while 30/20/10 departs more. Breaking the statistic into contributions reveals how discrepancies accumulate rather than showing only a p-value.

Two different questions

Goodness-of-fit H₀ specifies category probabilities; expectations equal the total times those probabilities, with df=k−1 in this version. Independence H₀ says the classifications are independent; expectations use row totals, column totals and the overall total, with df=(r−1)(c−1).

Counts and sampling design

Assign each independent observation to an appropriate mutually exclusive category. Repeated measurements or clustered household surveys do not become independent by being placed in a table. Expected counts must be positive; one effective category cannot support a meaningful goodness-of-fit test.

A large χ² is not an effect size

A larger sample can produce a larger χ² for the same proportional discrepancy. Cramér's V additionally scales association by sample size and table dimension. Read the actual proportions as well; V does not establish causal direction.

Another example

  1. Choose goodness-of-fit and enter counts with prespecified proportions, or supply a contingency table.
  2. Check proportion totals, expected counts and independent observations; set α.
  3. Read contributions, χ², df and p-value; independence also supplies Cramér’s V. Heed expected-count warnings.
Show formal definition and formula

Pearson's chi-square test compares categorical observed counts with expectations under a null model. Goodness-of-fit and independence share the statistic's form, but have different null hypotheses and df.

Observed versus expected

Expected counts

Contingency df and effect size

Oᵢ, Eᵢ
Observed and expected counts; enter counts, not percentages.
pᵢ, n
Prespecified probabilities (sum 1) and total count.
r, c, ν
Rows, columns and df; prespecified GOF df is categories−1.
V
Cramér's V association effect size; not causation.

Common mistakes

Percentages are not observed counts or sample sizes. Association is not causation. A chi-square right tail is not a symmetric two-tail calculation, and sparse expected counts do not become reliable just because a p-value was computed.

Frequently asked questions

Must every expected count exceed five?

Approximation quality depends on table size, sample size and the pattern of expectations. The tool flags cells below one, cells below five and their prevalence; a single cutoff is not a universal reliability guarantee.

Can I estimate the null proportions from these data?

This version restricts goodness-of-fit to prespecified theoretical proportions. It does not adjust df for parameters fitted from the same sample; in that setting k−1 cannot simply be retained.

Is Fisher's exact test available for sparse tables?

Fisher's exact test may be appropriate for some sparse contingency tables, but it is not implemented here. A chi-square approximation is not an exact Fisher result.

You can now explore…

  • Compare observed and expected counts
  • Check sparsity and categorical association