Skip to study

CHAPTER 08 · STATISTICS & PROBABILITY

Hypothesis testing & rank correlation

Progress stays on this device

papers AI SL chapter & section analysis

Your chapter

Choose a test that matches the data, check its assumptions and interpret the evidence.

Read all chapter notes

8.1

Spearman’s rank correlation

Spearman’s rank correlation rs measures association between ranks and is useful for ordinal data or a monotonic relationship that need not be linear. Rank both variables in the same direction, keeping observations paired. Strong increasing or decreasing rank patterns give values near 1 or −1.

Equal observations receive the mean⁡\displaystyle \operatorname{mean} of the ranks they occupy. For example, two tied observations in positions 2 and 3 each receive rank 2.5. The general calculator method is to calculate Pearson correlation on the two rank lists; do not apply the simple untied-rank formula blindly when ties occur.

A rank statistic uses relative order rather than the sizes of numerical gaps. Changing values without changing their paired rank order leaves rs unchanged. It is still sensitive to the data and does not prove causation. A coefficient near zero suggests little monotonic rank association, but it does not rule out a non-monotonic relationship.

For no ties: rs=1−6∑d2n(n2−1)\displaystyle rs = 1 - \frac{6 \sum d^{2}}{n \left(n^{2} - 1\right)}. With ties, assign mean⁡\displaystyle \operatorname{mean} ranks and calculate Pearson correlation of those rank lists.

Watch out: Use average ranks for ties and preserve pairing. Ranking one list ascending and the other descending reverses the intended sign.

Worked example

Five paired rankings have sum of squared rank differences ∑d2=4\displaystyle \sum d^{2} = 4, with no ties. Find Spearman’s rank correlation.

  1. Use rs=1−6×45(25−1)\displaystyle rs = 1 - \frac{6 \times 4}{5 \left(25 - 1\right)}.
  2. This is 1−24120=45\displaystyle 1 - \frac{24}{120} = \frac{4}{5}.

8.2

Chi-squared test for independence

A chi-squared independence test compares observed counts in a contingency table with counts expected if two categorical variables were independent. State H0 as independence and H1 as association, using the actual variables and population. Counts, rather than percentages or measurements, are the input.

For a table with r rows and c columns, each expected count is its row total times its column total divided by the grand total, and the degrees of freedom are (r−1)(c−1)\displaystyle \left(r - 1\right) \left(c - 1\right). Use independent observations and expected counts greater than 5 and degrees of freedom greater than 1 for the AI SL examination cases. Sparse categories may need a justified combination before testing.

The chi-squared statistic adds (O−E)2E\displaystyle \frac{\left(O - E\right)^{2}}{E} across every cell and its p-value is an upper-tail probability. At significance level α\displaystyle \alpha, reject H0 when p≤α\displaystyle p \le \alpha; otherwise there is insufficient evidence to reject it. A statistically significant association does not prove one variable causes the other.

Eij=(row total × column total)/grand total. χ2=∑(O−E)2E\displaystyle \chi^{2} = \frac{\sum \left(O - E\right)^{2}}{E}. df=(r−1)(c−1)\displaystyle df = \left(r - 1\right) \left(c - 1\right).

Watch out: A p-value is not the probability that H0 is true. A large p-value does not prove independence.

Worked example

A2×3\displaystyle A 2 \times 3 table of independent survey counts has rows (30, 20, 10)\displaystyle \left(30,\,20,\,10\right) and (20, 30, 10)\displaystyle \left(20,\,30,\,10\right). Find the expected count in the top-left cell and the chi-squared statistic, in that order.

  1. The row totals are 60 and 60, column totals 50,50,20, and grand total 120; E11=60×50120=25\displaystyle E 11 = \frac{60 \times 50}{120} = 25.
  2. Each expected row is (25, 25, 10)\displaystyle \left(25,\,25,\,10\right). Four non-zero contributions are 2525=1\displaystyle \frac{25}{25} = 1 each, giving χ2=4\displaystyle \chi^{2} = 4. Here df=2\displaystyle df = 2 and every expected count exceeds 5.

8.3

Chi-squared goodness of fit

A goodness-of-fit test compares observed category counts with a specified probability model for one variable. H0 states that the population follows the proposed category probabilities; H1 states that it does not. Expected counts equal the sample size times each hypothesised probability. For categories defined by intervals of a specified normal model, first obtain each interval probability with a normal CDF, then multiply by the sample size.

For k categories with fully specified probabilities and no fitted parameters, use k−1\displaystyle k - 1 degrees of freedom. The AI SL examination cases use expected counts greater than 5 and degrees of freedom greater than 1; if categories are combined for a sound reason, recompute the category count and degrees of freedom. A model with parameters estimated from the same sample needs an appropriate adjustment rather than automatic use of k−1\displaystyle k - 1.

Calculate χ2=∑(O−E)2E\displaystyle \chi^{2} = \frac{\sum \left(O - E\right)^{2}}{E} and compare its upper-tail p-value with the stated significance level. A small p-value is evidence against the proposed model; a large p-value means the data do not provide sufficient evidence against it. It does not prove the model is exactly true or tell you which alternative mechanism generated the observations.

Expected category count Ei=npi. χ2=∑(O−E)2E\displaystyle \chi^{2} = \frac{\sum \left(O - E\right)^{2}}{E}. For k fixed-probability categories and no fitted parameters: df=k−1\displaystyle df = k - 1.

Watch out: Use the model’s proposed probabilities for the expected list, not the observed proportions that would force a perfect fit.

Worked example

A fixed model assigns four categories equal probabilities. In 100 trials, counts are 18,22,20,40. Find χ2\displaystyle \chi^{2} to 2 decimal places.

  1. Each expected count is 100×14=25\displaystyle \frac{100 \times 1}{4} = 25.
  2. The statistic is 49+9+25+22525=30825=12.32\displaystyle \frac{49 + 9 + 25 + 225}{25} = \frac{308}{25} = 12.32.

8.4

The two-sample t-test

A two-sample t-test compares population means measured in the same units. State H0: μ1=μ2\displaystyle \mu 1 = \mu 2 and choose H1 before looking at the results: μ1≠μ2\displaystyle \mu 1 \ne \mu 2 for a difference, μ1>μ2\displaystyle \mu 1 > \mu 2 or μ1<μ2\displaystyle \mu 1 < \mu 2 for a directed claim. The hypotheses concern population means, not the observed sample means.

Use independent random samples and an appropriate approximately normal population model, particularly for small samples, with no severe influential outliers. The AI SL course uses the pooled two-sample test with an equal-population-variance assumption. Enter sample standard deviations and choose pooled: yes; the two sample sizes need not be equal. Distinguish the sample variances, which can differ, from the assumed equal population variances.

The GDC provides the test statistic and the p-value for the selected alternative. Compare p with the significance level, reject H0 when p≤α\displaystyle p \le \alpha and otherwise report insufficient evidence to reject it. Retain the unrounded p-value when comparing with α\displaystyle \alpha. A p-value does not measure the size or practical importance of the mean⁡\displaystyle \operatorname{mean} difference, and a test cannot repair an unrepresentative sampling method.

Pooled variance sp2=(n1−1)s12+(n2−1)s22n1+n2−2\displaystyle sp^{2} = \frac{\left(n 1 - 1\right) s 1^{2} + \left(n 2 - 1\right) s 2^{2}}{n 1 + n 2 - 2}. t=x‾1−x‾2sp1n1+1n2\displaystyle t = \frac{\overline{x} 1 - \overline{x} 2}{sp \sqrt{\frac{1}{n} 1 + \frac{1}{n} 2}}; df=n1+n2−2\displaystyle df = n 1 + n 2 - 2.

Watch out: Choose the correct alternative and pooling setting before calculating. A non-significant result does not prove equal population means.

Worked example

Independent approximately normal populations are assumed to have equal variances. Sample 1 has x‾1=42\displaystyle \overline{x} 1 = 42, s1=4\displaystyle s 1 = 4, n1=12\displaystyle n 1 = 12 and sample 2 has x‾2=38\displaystyle \overline{x} 2 = 38, s2=5\displaystyle s 2 = 5, n2=10\displaystyle n 2 = 10. Find the pooled two-sample t statistic to 3 decimal places.

  1. The pooled variance is 11×16+9×2520=40120=20.05\displaystyle \frac{11 \times 16 + 9 \times 25}{20} = \frac{401}{20} = 20.05.
  2. Using sample 1 minus sample 2 gives t=4[20.05(112+110)]=2.086325\displaystyle t = \frac{4}{\sqrt{\left[20.05 \left(\frac{1}{12} + \frac{1}{10}\right)\right]}} = 2.086325⋯\displaystyle \cdots , so t=2.086\displaystyle t = 2.086.