Before you start
You will be able to
- Calculate a two-proportion z test with the pooled standard error and a confidence interval for the difference in two proportions, and check their conditions.
- Describe the chi-square distribution and explain why chi-square tests use the right tail and how their degrees of freedom are counted.
- Test whether counts fit a stated model with a chi-square goodness-of-fit test, including a model whose parameter is estimated from the data, merging categories whose expected counts are too small.
- Test for independence in a contingency table: expected counts, the chi-square statistic, degrees of freedom, the p-value and the expected-count condition.
- Calculate chi-square tests in Excel with CHISQ.TEST, CHISQ.DIST.RT and CHISQ.INV.RT, and recognise when CHISQ.TEST uses the wrong degrees of freedom.
- Interpret a result with percentages, an interval or Cramér’s V, without treating a non-significant result as no difference or an association as a cause.
Review first
- Hypothesis testing — Null and alternative hypotheses, test statistics, p-values, α and the one-proportion z test are the starting point for every test here.
- Confidence intervals — The interval for one proportion, and its condition of at least 10 successes and 10 failures, extend to the difference between two.
- Probability — Contingency tables and independence, P(A and B) = P(A) × P(B), give the expected counts in a test of independence.
- Discrete distributions — The Poisson model of Lantern’s orders per day, which this lesson tests formally.
- Interpreting results: charts, comparisons and causes — B01’s comparison group for the September dip, and why association isn’t causation.
Fictional case A fictional coffee business founded by Ana Lim. It starts as a catering and barista-training service, opens its own cafés and an online shop for beans, and plans a canned cold brew.
The idea
Fictional case
In October Ana has three questions, all about counts. Web conversion fell from 2.91% in August to 1.80% in September, the month the redesigned checkout went live: a real fall, or the kind of wobble any month shows? Her spring orders seem to arrive unevenly across the week: are some weekdays really busier? And 57.6% of the spring’s app orders were subscriptions against 35.6% of web orders: does the app go with subscribing, or could a gap like that arise by chance?
Each question is about a categorical variable: a visit converts or doesn’t, an order falls on a weekday, a customer orders through the web or the app and subscribes or doesn’t. The data are counts, and each question asks whether the counts differ from what a null hypothesis predicts by more than chance would explain. The logic is the one in Hypothesis testing: state the null hypothesis, measure how far the data sit from it with a test statistic, and turn that distance into a p-value. This lesson adds two test statistics, one for comparing two proportions and one for comparing counts with a model.
Two proportions: was September’s fall real?
In August 224 of the 7,700 web visits ended in an order, a sample proportion of 2.91%. In September 158 of 8,800 did: 1.80%. The fall is 1.11 percentage points. The null hypothesis says the two months had the same underlying conversion rate, , and the gap is chance: which visitors happened to arrive and which of them happened to buy.
If the null hypothesis is true there is one conversion rate, and the best estimate of it pools both months: 224 + 158 = 382 orders in 7,700 + 8,800 = 16,500 visits, so . The standard error of the difference between two sample proportions is worked out from that pooled rate. With and , it is , or 0.2347 percentage points. The observed gap of 1.114 points is standard errors.
If the null hypothesis were true, z would follow the standard normal distribution approximately, and a value 4.75 or more from 0 in either direction has a probability of about 0.000002, two in a million. This is the two-proportion z test. A gap this large is far beyond the month-to-month wobble of a steady 2.3% rate: the evidence that conversion really fell is overwhelming. A 95% confidence interval for the fall, worked out in the In depth section, runs from 0.65 to 1.58 percentage points, and at September’s 8,800 visits a fall of 1.11 points is about 98 orders.
The test says the fall is very unlikely to be chance; it doesn’t say why. B01’s comparison group helps: app buyers never saw the new website checkout, and app conversion was 3.68% in August and 3.58% in September. The same test on the app gives z = 0.20 and p = 0.84, no evidence of any change. A fall confined to the channel that got the new checkout supports the checkout as the cause, but it doesn’t prove causation: anything else that changed only on the website in September could produce the same pattern.
Counts against a model: the chi-square statistic
Ana’s second question involves seven categories at once. Over the 122 spring days the shop took 231 orders. If the weekday made no difference, every day would have the same expected number of orders, 231 ÷ 122 ≈ 1.89, and each weekday’s expected count would be that rate times the number of such days. The spring had 18 Mondays, Tuesdays and Sundays but 17 of each other weekday, so the expected counts are not 231 ÷ 7 = 33 each: Monday’s is 231 × 18 ÷ 122 ≈ 34.08.
| Weekday | Days | Orders (O) | Expected (E) | (O − E)² ÷ E |
|---|---|---|---|---|
| Monday | 18 | 39 | 34.08 | 0.710 |
| Tuesday | 18 | 30 | 34.08 | 0.489 |
| Wednesday | 17 | 37 | 32.19 | 0.719 |
| Thursday | 17 | 27 | 32.19 | 0.836 |
| Friday | 17 | 38 | 32.19 | 1.049 |
| Saturday | 17 | 34 | 32.19 | 0.102 |
| Sunday | 18 | 26 | 34.08 | 1.917 |
| Total | 122 | 231 | 231.00 | 5.822 |
The chi-square statistic adds up, over the categories, each squared gap between an observed count and its expected count divided by the expected count: . Squaring makes every gap count as positive, and dividing by E scales it, because a gap of 5 matters more when 10 were expected than when 1,000 were. Sunday contributes most: 26 orders where 34.08 were expected, . In all, .
When the null hypothesis is true and the expected counts are large enough, χ² follows approximately a chi-square distribution, a family of right-skewed distributions indexed by their degrees of freedom. Here there are 7 − 1 = 6: once six of the observed counts are known, the seventh is fixed by the total of 231. The p-value is the area to the right of 5.82 under that curve, =CHISQ.DIST.RT(5.82,6) ≈ 0.44.
A p-value of 0.44 says that gaps of this size between the weekdays would be common if the order rate were the same every day. So there is no evidence that some weekdays are busier: Monday’s 2.17 orders a day and Sunday’s 1.44 are within the range chance produces when each weekday has only about 33 orders. That isn’t proof that the rates are equal, only that these 231 orders can’t tell them apart.
Two categorical variables: does the app go with subscribing?
Ana’s third question crosses two variables. Each of the 231 spring orders has a channel and a subscription status, so the orders fall into a 2 × 2 contingency table: a table of counts with one variable in the rows and the other in the columns.
| Channel | Subscription | One-off | Total | Subscription share |
|---|---|---|---|---|
| Web | 47 | 85 | 132 | 35.6% |
| App | 57 | 42 | 99 | 57.6% |
| Total | 104 | 127 | 231 | 45.0% |
The null hypothesis of a test of independence is that the two variables are independent: the chance that an order is a subscription is the same whichever channel it came through. Overall 104 of the 231 orders, 45.0%, were subscriptions, so under independence 45.0% of the 132 web orders, 59.43, would be subscriptions. In general the expected count for a cell is its row total times its column total divided by the grand total.
| Channel | Subscription | One-off | Total |
|---|---|---|---|
| Web | 59.43 | 72.57 | 132 |
| App | 44.57 | 54.43 | 99 |
| Total | 104 | 127 | 231 |
The web had 12.43 fewer subscriptions than independence predicts, and the app 12.43 more. Summing over the four cells gives with degree of freedom, and =CHISQ.DIST.RT(11.03,1) ≈ 0.0009. Gaps this large would arise in fewer than one sample in a thousand if channel and subscription were independent: strong evidence that they are associated. The same test on star ratings finds nothing: 44.0% of rated web orders and 44.3% of rated app orders had five stars, giving and .
In depth
The two-proportion z test
Two independent samples of sizes and contain and successes, giving sample proportions and . To test , the standard error uses the pooled proportion , because under the null hypothesis both samples estimate the same p and the combined sample estimates it best. The test statistic divides the gap between the sample proportions by that standard error:
z is compared with the standard normal distribution: two-sided for , one-sided for or , a choice made before looking at the data.
Its conditions are those of the one-proportion test, applied to each sample:
- Independence. The two samples are independent of each other, and the observations within each are independent: random samples, randomly assigned groups or, for a process such as Lantern’s visits, trials that don’t influence one another.
- Large enough counts. At least 10 successes and 10 failures in each sample, so that the normal approximation holds. OpenStax’s Introductory Business Statistics asks for at least 5; 10 is the more cautious rule and the one this course uses for intervals. Lantern’s counts (224 and 7,476 in August, 158 and 8,642 in September) pass easily.
- A small fraction of the population. When samples are drawn without replacement from a finite population, OpenStax adds that the population should be at least 10 to 20 times the size of the sample.
Lantern’s visits bend the independence condition: one person can visit several times in a month, and their visits are related. Related trials can make the formula’s standard error too small, so a borderline z would deserve caution. A z of 4.75 is not borderline.
Excel has no function for a two-proportion test, so build it from cells. With the orders in B2:C2 and the visits in B3:C3, the pooled proportion is =(B2+C2)/(B3+C3); with that in B6, the standard error is =SQRT(B6*(1-B6)*(1/B3+1/C3)); and with z in B8, the two-sided p-value is =2*(1-NORM.S.DIST(ABS(B8),TRUE)). For a one-sided alternative, =1-NORM.S.DIST(B8,TRUE) gives P(Z > z), the p-value for , and =NORM.S.DIST(B8,TRUE) gives P(Z < z), the p-value for .
A confidence interval for the difference
An interval estimates how big the difference is, not only whether it is zero. It doesn’t assume the two proportions are equal, so it uses each sample’s own proportion in an unpooled standard error:
Here for 95%. For Lantern the unpooled standard error is 0.002382, the margin , and the interval : 0.65 to 1.58 percentage points.
Because the test and the interval use slightly different standard errors, they can disagree when a result is borderline: an interval that just excludes 0 alongside a p-value just above 0.05. Far from the line, as here, they agree. Report the interval with the test: “conversion fell by 1.1 points (95% CI 0.6 to 1.6)” says both that the fall is unlikely to be chance and how large it might be. In relative terms September converted at 62% of August’s rate, a fall of 38%.
The chi-square distribution
A chi-square distribution with k degrees of freedom is the distribution of the sum of the squares of k independent standard normal variables. It is never negative and it is skewed to the right; its mean equals its degrees of freedom and its standard deviation is √(2k). As the degrees of freedom grow, it moves right, spreads out and becomes more symmetric.
Why does the χ² statistic follow it? When counts are large, each standardised gap behaves roughly like a standard normal value, so their squares add up like a chi-square variable. The gaps are not all free, though: they must add to 0, because the observed and expected counts share a total, and every quantity estimated from the data adds another constraint. Each constraint removes one degree of freedom. The approximation is poor when expected counts are small, which is where the rule of at least 5 comes from.
Excel’s functions: =CHISQ.DIST.RT(x,deg_freedom) returns the right-tail probability P(χ² > x), the p-value of a chi-square test; Microsoft’s example, =CHISQ.DIST.RT(18.307,10), returns 0.0500006. =CHISQ.INV.RT(probability,deg_freedom) goes the other way and returns the critical value: =CHISQ.INV.RT(0.05,6) ≈ 12.59 for the weekday test. =CHISQ.DIST(x,deg_freedom,TRUE) returns the left-tail probability, the wrong one for a p-value. Both right-tail functions truncate a deg_freedom that isn’t a whole number.
Goodness-of-fit tests
A goodness-of-fit test asks whether one categorical variable follows a stated distribution: a planned product mix, equal rates per day, a Poisson model. The steps:
- State the model as a probability for each of the k categories. The probabilities come from the null hypothesis, not from the counts being tested.
- Multiply by the sample size to get the expected counts, . They needn’t be whole numbers.
- Check that every expected count is at least 5. If one isn’t, merge it with a neighbouring category, and make sure the categories between them cover every possible value.
- Calculate χ² and its degrees of freedom, , where m is the number of the model’s parameters estimated from the same data.
- Find the right-tail p-value with CHISQ.DIST.RT, and state the conclusion in context.
The rule of 5 is a convention. OpenStax states it, and Microsoft’s CHISQ.TEST page says that some statisticians suggest it; NIST’s e-Handbook asks only for a sufficient sample size and warns that the result depends on how the data are binned. OpenStax calls the goodness-of-fit test “almost always right-tailed”: large values of χ² are the evidence against the model. The rare exception is a χ² far below its degrees of freedom, which can mean data that fit too well, for example because they were tidied.
Estimated parameters cost degrees of freedom. To test whether orders per day follow a Poisson distribution, Ana must estimate λ from the same 122 days, and a model fitted to the data matches them better than a model fixed in advance. To allow for that, the statistic is compared with a chi-square distribution with one degree of freedom fewer. NIST’s handbook gives the general rule: k − c degrees of freedom, where c is the number of estimated parameters plus 1.
In Excel, =CHISQ.TEST(actual_range,expected_range) returns the p-value directly from two ranges of the same size. For a single column of k categories it uses k − 1 degrees of freedom, which is right only when no parameter was estimated. Otherwise calculate χ² yourself, for example =SUMPRODUCT((B2:B7-D2:D7)^2/D2:D7) with the observed counts in B and the expected counts in D, and take =CHISQ.DIST.RT with the correct degrees of freedom.
The test of independence
For a table with r rows and c columns, the null hypothesis is that the row variable and the column variable are independent, and the alternative is that they are associated. Independence means P(row i and column j) = P(row i) × P(column j), as in Probability. Estimating each probability by its share of the grand total n and multiplying by n gives the expected count : the row total times the column total over the grand total.
The degrees of freedom are : with the row and column totals fixed, once cells are filled in, the rest are determined. Lantern’s five regions by subscription status, a 5 × 2 table, have 4. The conditions:
- The table counts individuals (orders, customers, bookings), each in exactly one cell. Percentages and averages can’t go into a chi-square test.
- The observations are independent. Several orders from one customer bend this condition, as repeat visits did for conversion.
- Every expected count is at least 5. OpenStax: “The expected value inside each cell needs to be at least five in order for you to use this test.” If one isn’t, merge categories that belong together or collect more data.
In Excel, build the expected table first. With the observed counts in B2:C3, the row totals in D2:D3, the column totals in B4:C4 and the grand total in D4, type =$D2*B$4/$D$4 in the top-left expected cell and fill it across and down. =CHISQ.TEST(B2:C3,B7:C8) then returns the p-value with (r − 1)(c − 1) degrees of freedom, or #N/A if the two ranges hold different numbers of values. It doesn’t return χ² itself; for a report, calculate it with SUMPRODUCT.
When each row is a separate sample, for example a survey of 200 web customers and 200 app customers, the same calculation is called a test of homogeneity: are the column proportions the same in every row? The arithmetic and the conditions don’t change.
Two-by-two tables: χ² = z²
A 2 × 2 table holds two proportions, so the chi-square test and the two-proportion z test can be run on the same counts. They agree exactly. For Lantern’s channels the z test of the app’s subscription share against the web’s gives , and , with the same p-value, 0.0009. The chi-square test is the two-sided z test; use the z test when you want a one-sided alternative or an interval, here a gap of 22.0 points with a 95% interval of 9.3 to 34.7 points.
Some textbooks and some software apply a continuity correction to 2 × 2 tables, which makes χ² a little smaller. Excel’s CHISQ.TEST works from the formula above without one, and so does this lesson, which is why its results match the z test.
How strong, and what it doesn’t show
A p-value measures evidence, not size. With thousands of observations a trivial association is statistically significant; with a few dozen a large one may not be. Report an effect size alongside: the percentages being compared and, for a larger table, Cramér’s V, , which runs from 0 (counts that match independence exactly) to 1 (complete association). Lantern’s channel and subscription give V ≈ 0.22, its ratings by channel V ≈ 0.002, and its regions by subscription V ≈ 0.34, driven by the East’s 75% subscription share against 32% to 44% elsewhere.
A non-significant result is not evidence of no difference. The rated orders’ five-star shares differ by only 0.2 points, but the 95% interval for the difference runs from −15.5 to +16.0 points: 154 ratings can’t rule out a sizeable gap either way.
And association is not causation. App orders were subscriptions more often, but customers chose their channel: committed regulars may be the ones who install an app and the ones who subscribe, a confounding variable that a chi-square test can’t see. The test says the pattern is unlikely to be chance; whether the app causes subscriptions needs a comparison in which customers don’t choose, such as a randomised trial. Finally, every test carries its α risk: run chi-square tests on twenty cross-tabulations of the same orders and about one will be significant at the 5% level by chance alone, the multiple testing problem from Hypothesis testing.
Formulas
Two-proportion z test (pooled standard error)
- Successes in samples 1 and 2counts
- Sample sizescounts
- Sample proportions, x ÷ n
- Pooled proportion: all successes over all observations
- Test statistic, compared with the standard normal distribution
Assumes. Independent samples (or independent trials); at least 10 successes and 10 failures in each sample.
Tests H₀: p₁ = p₂. The p-value is 2 × (1 − NORM.S.DIST(|z|, TRUE)) for a two-sided alternative.
Confidence interval for a difference in two proportions
- Sample proportions
- Sample sizescounts
- Standard normal critical value: NORM.S.INV(0.975) ≈ 1.96 for 95%
Assumes. As for the test, with at least 10 successes and 10 failures in each sample.
The interval uses each sample’s own proportion (unpooled), because it doesn’t assume p₁ = p₂.
Chi-square statistic
- Observed count in a category or cellcount
- Expected count under the null hypothesiscount
- Chi-square statistic, summed over every category or cell
Assumes. Counts of independent individuals; every expected count at least 5.
The p-value is the right-tail area, CHISQ.DIST.RT(χ², df).
Goodness of fit: expected counts and degrees of freedom
- Total number of observationscount
- Probability of category i under the null hypothesis
- Number of categories (after any merging)
- Number of the model’s parameters estimated from the same data
- Expected count in category icount
CHISQ.TEST on one column uses k − 1 degrees of freedom, so it is wrong when m > 0.
Test of independence: expected counts and degrees of freedom
- Total of row icount
- Total of column jcount
- Grand totalcount
- Numbers of rows and columns
- Expected count in row i, column j, if the variables are independentcount
In Excel: =$D2*B$4/$D$4 filled across the expected table, then =CHISQ.TEST(observed,expected).
Cramér’s V
- Chi-square statistic of the test of independence
- Grand totalcount
- Numbers of rows and columns
- Strength of association, from 0 (none) to 1 (complete)
For a 2 × 2 table, V equals the absolute value of the phi coefficient.
Worked examples
Fictional figures
Millstone Bakery plans its Saturday bake on a mix of 40% sourdough, 30% white, 20% rye and 10% spelt. Last Saturday it sold 200 loaves: 92 sourdough, 54 white, 38 rye and 16 spelt. Do the sales fit the planned mix, at the 5% level?
| Loaf | Planned share | Sold (O) | Expected (E) | (O − E)² ÷ E |
|---|---|---|---|---|
| Sourdough | 40% | 92 | 80 | 1.8 |
| White | 30% | 54 | 60 | 0.6 |
| Rye | 20% | 38 | 40 | 0.1 |
| Spelt | 10% | 16 | 20 | 0.8 |
| Total | 100% | 200 | 200 | 3.3 |
- Hypotheses: H₀, customers buy in the planned proportions 0.4, 0.3, 0.2 and 0.1; H₁, at least one proportion differs.
- Expected counts, : , , and . All are at least 5, so the chi-square approximation is reasonable.
- Contributions: , , and , so .
- Degrees of freedom: 4 − 1 = 3, since no parameter was estimated.
=CHISQ.DIST.RT(3.3,3)≈ 0.35, and the 5% critical value=CHISQ.INV.RT(0.05,3)≈ 7.81 is well above 3.3. With the sales in C2:C5 and the expected counts in D2:D5,=CHISQ.TEST(C2:C5,D2:D5)returns the same p-value in one step.
Answer. χ² = 3.3 with 3 degrees of freedom, p ≈ 0.35: no evidence at the 5% level that Saturday’s sales differ from the planned mix.
What it means. Sourdough sold 12 loaves more than planned, but a gap of that size is common by chance in 200 sales. One Saturday is a small test, and loaves bought together by one customer aren’t independent sales, so the bakery should keep the plan and keep counting: several weeks of data would show a real shift in demand that one day can’t.
Fictional figures
Hollybank Hotel took 600 bookings for July to September: 180 direct, 300 through online travel agencies and 120 corporate. Of these, 18, 66 and 12 were cancelled. Is cancellation associated with the booking channel? If so, how strongly, and where is the difference?
| Channel | Cancelled | Not cancelled | Total | Cancelled share |
|---|---|---|---|---|
| Direct | 18 | 162 | 180 | 10% |
| Travel agency | 66 | 234 | 300 | 22% |
| Corporate | 12 | 108 | 120 | 10% |
| Total | 96 | 504 | 600 | 16% |
- Expected counts under independence: 96 of the 600 bookings, 16%, were cancelled, so each channel’s expected cancellations are 16% of its bookings: 28.8 direct, 48.0 travel agency and 19.2 corporate, leaving 151.2, 252.0 and 100.8 not cancelled. The smallest expected count is 19.2, so the condition holds.
- Contributions : direct 4.05 and 0.77, travel agency 6.75 and 1.29, corporate 2.70 and 0.51. The total is .
- Degrees of freedom: .
=CHISQ.DIST.RT(16.07,2)≈ 0.0003, and the 5% critical value=CHISQ.INV.RT(0.05,2)≈ 5.99, so the result is significant well beyond the 5% level. - Size: . Where: the largest contributions come from the travel-agency cancellations (66 against 48.0 expected) and the direct ones (18 against 28.8). Travel-agency bookings cancelled at 22%, the other two channels at 10%.
Answer. χ² ≈ 16.07 with 2 degrees of freedom, p ≈ 0.0003, V ≈ 0.16: cancellation is associated with booking channel, travel-agency bookings cancelling at 22% against 10% for direct and corporate bookings.
What it means. The test establishes a pattern, not its cause. Travel-agency bookings may differ in other ways: many come with free cancellation, are made further ahead, or are made by guests holding rooms at several hotels. The hotel might ask for a deposit or overbook agency rooms slightly, but it should try such a change on part of its bookings and measure it before relying on it. The test treats the channels as unordered categories, so listing them in another order gives the same χ².
Fictional figures
Discrete distributions compared Lantern’s spring orders per day with a Poisson distribution with λ = 231 ÷ 122 ≈ 1.89. Test the fit formally. Ana’s frequency table of the 122 days: 18 days with no orders, 35 with one, 33 with two, 18 with three, 14 with four and 4 with five; no day had more.
| Orders in a day | Days (O) | Poisson probability | Expected (E) | (O − E)² ÷ E |
|---|---|---|---|---|
| 0 | 18 | 0.1506 | 18.37 | 0.007 |
| 1 | 35 | 0.2851 | 34.78 | 0.001 |
| 2 | 33 | 0.2699 | 32.92 | 0.000 |
| 3 | 18 | 0.1703 | 20.78 | 0.372 |
| 4 | 14 | 0.0806 | 9.84 | 1.762 |
| 5 or more | 4 | 0.0436 | 5.31 | 0.325 |
| Total | 122 | 1.0000 | 122.00 | 2.468 |
- The categories must cover every possible count, so the last one is “5 or more”, not “5”: its probability is
=1-POISSON.DIST(4,231/122,TRUE)≈ 0.0436, and its expected count 122 × 0.0436 ≈ 5.31. Splitting it into “5” (3.73 expected) and “6 or more” (1.59) would leave two expected counts below 5, so they stay merged. - The other expected counts are 122 ×
=POISSON.DIST(k,231/122,FALSE)for k = 0 to 4: 18.37, 34.78, 32.92, 20.78 and 9.84. All six expected counts are at least 5. - . The largest contribution is the 14 days with four orders, where 9.84 were expected.
- Degrees of freedom: 6 categories − 1 − 1 estimated parameter (λ) = 4, and
=CHISQ.DIST.RT(2.47,4)≈ 0.65. With the days in B2:B7 and the expected counts in D2:D7,=CHISQ.TEST(B2:B7,D2:D7)would use 5 degrees of freedom and report 0.78, because it can’t know that λ came from the same data. Strictly, because λ was estimated from the ungrouped daily counts rather than from this grouped table, the exact p-value lies between the 4-df and 5-df values (0.65 and 0.78); the conclusion is the same either way.
Answer. χ² ≈ 2.47 with 4 degrees of freedom, p ≈ 0.65: no evidence against a Poisson model for orders per day.
What it means. The Poisson model is a reasonable working description of spring demand, so Ana can use it for planning, for example the 4% chance of a day with five or more orders. A good fit doesn’t prove the model: with 122 days the test can detect only fairly large departures. And the rate itself changed after the July relaunch, when the shop took between 8 and 19 orders a day, so a model fitted to the spring says nothing about the autumn.
Fictional figures
Ana is considering spending $1,500 on promoting the app to web customers, on the reasoning that app customers subscribe more. Using the 231 spring orders, how strong is the evidence that the subscription share differs by channel, how big is the difference, and does it support the spending?
- Describe: 57 of 99 app orders (57.6%) and 47 of 132 web orders (35.6%) were subscriptions, a gap of 22.0 percentage points.
- Check: the data are counts of orders in a 2 × 2 table, each order in one cell, and the smallest expected count is 44.57, far above 5. Some customers ordered more than once, a mild breach of independence worth stating.
- Test: with 1 degree of freedom, p ≈ 0.0009 (
=CHISQ.TEST(B2:C3,B7:C8)on the observed and expected tables); the two-proportion test gives and the same p-value. Strong evidence of an association. - Size: the 95% interval for the gap runs from 9.3 to 34.7 points, and V ≈ 0.22. The interval is wide because 99 and 132 orders are not many.
- Cause: customers chose their channel. Regular customers may be more likely both to install the app and to subscribe, so the gap may reflect who uses the app rather than what the app does.
Answer. The subscription share is associated with channel: 22.0 points higher for app orders (95% CI 9.3 to 34.7 points; p ≈ 0.0009). The data can’t show that moving a customer to the app would make them subscribe.
What it means. The evidence justifies a closer look, not spending on the assumption that the app causes subscriptions. Ana could ask app subscribers why they subscribed or follow customers who switch to the app, but only a randomised comparison would settle the causal question. The spring orders also predate the July relaunch, so she should check the pattern in the autumn’s orders before acting.
Explore
Common mistakes
“CHISQ.TEST wants the expected proportions.”
It wants expected counts, with the same total as the observed counts. Given proportions such as 0.4 and 0.3, it compares 92 loaves with 0.4 of a loaf and returns a p-value of essentially 0. Multiply the proportions by n first.
“Equal categories mean equal expected counts.”
Only if the categories are equally likely under the null hypothesis. Lantern’s spring had 18 Mondays and 17 Thursdays, so equal daily rates predict more Monday orders. Build the expected counts from the model, not from k equal shares.
“CHISQ.TEST always uses the right degrees of freedom.”
It uses k − 1 for one column and (r − 1)(c − 1) for a table. When a parameter such as λ was estimated from the data, the correct df is smaller: calculate χ² with SUMPRODUCT and use CHISQ.DIST.RT with k − 1 − m.
“Pool the proportions for the interval too.”
The test pools because it assumes p₁ = p₂. The interval estimates the difference, so it uses each sample’s own proportion. Use the pooled standard error for z and the unpooled one for the interval.
“p = 0.98, so web and app customers rate Lantern the same.”
A large p-value means no evidence of a difference, not evidence of none. The five-star shares could differ by up to 16 points either way on these 154 ratings: fail to reject is not accept.
“The chi-square test shows the app causes subscriptions.”
A significant chi-square says two variables are associated beyond chance. Customers chose their channel, so a confounder such as loyalty can produce the association. Causal claims need a design in which the groups don’t choose themselves.
Guided practice
Work through these with hints when you need them. Every hint and every worked solution is there to be used.
Loading four questions…
On your own
No hints this time. Answer, check, and read the feedback; the solution appears once you have answered or if you ask for it. Your first answers count toward mastery.
Loading six questions…
In practice
Cross-tabulations are among the commonest tables in business reporting: complaints by product, churn by plan, defects by production line, survey answers by customer segment. A chi-square test is the check that a pattern in such a table is larger than chance before anyone acts on it, and a two-proportion test with its interval is the standard way to compare two rates, such as a defect rate before and after a change of supplier. Survey researchers run the same tests on questionnaire data, with the sampling caveats that M04 Market Research covers.
Fictional case
Ana writes three lines for her October review. “Web conversion fell from 2.91% in August to 1.80% in September (z = 4.75, p < 0.0001): a fall of 1.1 points (95% CI 0.6 to 1.6), about 98 orders a month. App conversion didn’t change (p = 0.84), which points at the new website checkout.” “Spring orders show no weekday pattern (χ² = 5.82, 6 df, p = 0.44), so packing and staffing stay the same every day.” “App orders were subscriptions far more often than web orders (57.6% against 35.6%; χ² = 11.0, p = 0.0009, V = 0.22), but customers choose their channel, so this doesn’t show that moving customers to the app would raise subscriptions.”
The habit to take from her review is a reporting standard: the counts and percentages, the test and its p-value, an interval or an effect size, and the conditions that might weaken the conclusion, followed by what the result does and doesn’t license. A p-value on its own answers none of the questions a manager asks next: how big, how sure, and why.
Knowledge check
Six questions, one attempt each, no hints. Score 80% or more to complete the lesson; you can take it again at any time.
Loading six questions…
Summary
- The two-proportion z test compares two rates: z = (p̂₁ − p̂₂) ÷ √(p̄(1 − p̄)(1/n₁ + 1/n₂)), with the pooled proportion p̄. The interval for p₁ − p₂ uses the unpooled standard error.
- Conditions for both: independent samples or trials, and at least 10 successes and 10 failures in each sample.
- χ² = Σ(O − E)² ÷ E compares observed with expected counts; under the null hypothesis it follows a chi-square distribution, right-skewed with mean equal to its degrees of freedom. The p-value is, almost always, the right tail: CHISQ.DIST.RT.
- Goodness of fit: E = n × p from the model, df = k − 1 − m (m parameters estimated from the data). Merge categories until every expected count is at least 5.
- Independence: E = row total × column total ÷ n, df = (r − 1)(c − 1). CHISQ.TEST(observed, expected) returns the p-value; it needs expected counts, not proportions, and it can’t allow for estimated parameters.
- For a 2 × 2 table χ² = z²: the chi-square test is the two-sided two-proportion test.
- Report size as well as significance (percentages, an interval, Cramér’s V). A non-significant result is not proof of no difference, and an association is not a cause.
Key formulas
- Two-proportion z test (pooled standard error)
- Confidence interval for a difference in two proportions
- Chi-square statistic
- Goodness of fit: expected counts and degrees of freedom
- Test of independence: expected counts and degrees of freedom
- Cramér’s V
Terms introduced
- Two-proportion z test
- A test of whether two population proportions are equal, using z = (p̂₁ − p̂₂) divided by the standard error worked out from the pooled proportion, compared with the standard normal distribution.
- Pooled proportion
- The proportion of successes in two samples combined, (x₁ + x₂) ÷ (n₁ + n₂): the estimate of a common proportion used in the standard error of a two-proportion z test.
- Expected count
- The number of observations a category or cell would be expected to hold if the null hypothesis were true: n × p for a goodness-of-fit test, row total × column total ÷ n for a test of independence.
- Chi-square statistic
- χ² = Σ(O − E)² ÷ E, the sum over categories or cells of the squared difference between the observed and expected counts divided by the expected count. It is 0 when every count matches its expectation.
- Chi-square distribution
- The distribution of the sum of the squares of k independent standard normal variables, k being its degrees of freedom. It is never negative and is skewed to the right, with mean k; chi-square tests use its right tail.
- Goodness-of-fit test
- A chi-square test of whether the counts of one categorical variable follow a stated distribution, with k − 1 − m degrees of freedom for k categories and m parameters estimated from the data.
- Test of independence
- A chi-square test of whether two categorical variables are related, comparing a contingency table’s counts with the counts expected if they were independent; (r − 1)(c − 1) degrees of freedom.
- Cramér’s V
- A measure of the strength of association in a contingency table, √(χ² ÷ (n × min(r − 1, c − 1))), from 0 for no association to 1 for complete association.
Sources
- Holmes, A., Illowsky, B. & Dean, S. (2017). Introductory Business Statistics, section 10.4, “Comparing Two Independent Population Proportions”. OpenStax. openstax.org/books/introductory-business-statistics/pages/10…
- Holmes, A., Illowsky, B. & Dean, S. (2017). Introductory Business Statistics, section 11.3, “Goodness-of-Fit Test”, and section 11.4, “Test of Independence”. OpenStax. openstax.org/books/introductory-business-statistics/pages/11…
- Holmes, A., Illowsky, B. & Dean, S. (2017). Introductory Business Statistics, chapter 11, “Formula Review” (the chi-square distribution’s mean and standard deviation). OpenStax. openstax.org/books/introductory-business-statistics/pages/11…
- NIST/SEMATECH. e-Handbook of Statistical Methods, section 1.3.5.15, “Chi-Square Goodness-of-Fit Test”. itl.nist.gov/div898/handbook/eda/section3/eda35f.htm
- Microsoft Support. “CHISQ.TEST function”, with the pages for CHISQ.DIST.RT and CHISQ.INV.RT. support.microsoft.com/en-us/excel/chisq-test-function
- Weisstein, E. W. “Cramér’s V”. MathWorld, a Wolfram Resource. mathworld.wolfram.com/CramersV.html
