4.11 Hypothesis testing: chi-squared and t-tests

4.11 Hypothesis testing: chi-squared and t-tests

IB Maths: Applications and Interpretation HL: Revision notes

Studying this course? Keep your progress in one place.

Key facts

  • A test compares the pp-value with the significance level: if p<p< level, reject H0H_0.
  • Never say H0H_0 is proved; say there is, or is not, enough evidence and answer in context.
  • The χ2\chi^2 test for independence uses E=row total×column totalgrand totalE=\dfrac{\text{row total}\times\text{column total}}{\text{grand total}} and ν=(r−1)(c−1)\nu=(r-1)(c-1).
  • The χ2\chi^2 goodness of fit test uses ν=n−1\nu=n-1 when no parameters are estimated.
  • The pooled tt-test compares two means: unpaired samples, normal data, equal variances.

Hypotheses and p-values

Compare the pp-value with the significance level: if pp is smaller, reject H0H_0.

The null hypothesis H0H_0 is the claim being tested. The alternative hypothesis H1H_1 is what we accept if the evidence is strong enough: ≠\neq is two-tailed, >> or << is one-tailed.

The significance level (often 1%1\%, 5%5\% or 10%10\%) is the probability of rejecting H0H_0 when it is true. The p-value is the probability of a result at least as extreme as the one seen, if H0H_0 is true.

Conclude in context: "there is evidence that…" or "there is not enough evidence that…".

  1. 1

    State H0 and H1

    and the significance level

  2. 2

    Calculate

    the test statistic and p-value (GDC)

  3. 3

    Compare

    p with the significance level

  4. 4

    Conclude in context

    reject or do not reject H0

The logic of every hypothesis test

A test at the 5%5\% level gives p=0.08p=0.08. What is the correct decision?

Chi-squared test for independence

Compare observed counts with the counts expected if the variables were independent.

H0H_0: the variables are independent. H1H_1: they are associated.

Put the observed frequencies in a contingency table. The expected frequency of each cell is found from the totals, and the statistic is χ2=∑(O−E)2E\chi^2=\sum\frac{(O-E)^2}{E} with degrees of freedom ν=(r−1)(c−1)\nu=(r-1)(c-1).

Reject H0H_0 if χ2\chi^2 is above the critical value, or if p<p< the significance level. Use your GDC. Check that every expected frequency is greater than 55.

  • Expected frequencyE=row total×column totalgrand totalE=\dfrac{\text{row total}\times\text{column total}}{\text{grand total}}
  • Degrees of freedomν=(rows−1)(columns−1)\nu=(\text{rows}-1)(\text{columns}-1)
24681012140.050.10.150.20.250.3xycritical value 7.81chi-squared density, v = 3
Chi-squared distribution with 3 degrees of freedom: at the 5% level reject H0 in the shaded upper tail (critical value 7.81).

Worked example

Year 1010 travel 20,30,2520,30,25 and Year 1111 travel 30,25,2030,25,20 (walk, bus, car). Test for an association at 5%5\%.

A contingency table has 33 rows and 44 columns. How many degrees of freedom does the test have?

Chi-squared goodness of fit

Compare observed counts with the counts the distribution predicts; a large χ2\chi^2 means a poor fit.

H0H_0: the data fit the distribution (for example equally likely categories). H1H_1: they do not.

Expected frequencies are the total times the probability of each category. For nn categories with no parameters estimated, the degrees of freedom are ν=n−1\nu=n-1.

Then χ2=∑(O−E)2E\chi^2=\sum\frac{(O-E)^2}{E}. Compare with the critical value, or compare pp with the significance level.

010203040506070ABCDDessertCustomers
  • Observed
  • Expected
Observed and expected counts for 200 customers choosing among 4 desserts.

Worked example

200200 customers choose among 44 desserts: 68,52,44,3668,52,44,36. Test at 5%5\% whether the choices are equally likely.

A die is rolled 6060 times to test whether it is fair. What are the expected frequency and ν\nu?

The t-test for two means

The tt-test uses sample means to test whether two population means differ.

In examinations the samples are unpaired, the population variance is unknown and the variances are assumed equal, so the pooled two-sample t-test is used. Both populations must be normally distributed.

H0:μA=μBH_0:\mu_A=\mu_B, with H1:μA≠μBH_1:\mu_A\neq\mu_B (two-tailed) or H1:μA>μBH_1:\mu_A>\mu_B (one-tailed).

Enter the sample means, standard deviations and sizes into the GDC, choose the correct alternative, and compare the pp-value with the significance level.

−4−3−2−112340.10.20.30.4xy1.7252.086−2.086t, df = 20
t distribution with 20 degrees of freedom (12 + 10 − 2). Shaded: the 5% upper tail beyond 1.725. A two-tailed test at 5% uses ±2.086.

One-tailed

Alternative:
H1:μA>μBH_1:\mu_A>\mu_B
Wording:
"greater than", "less than"
The p-value:
Half the two-tailed value

Two-tailed

Alternative:
H1:μA≠μBH_1:\mu_A\neq\mu_B
Wording:
"different from"
The p-value:
Counts both tails

Worked example

Class A (1212 students, mean 68.468.4, standard deviation 7.27.2) and class B (1010 students, mean 62.162.1, standard deviation 8.18.1). Test H1:μA>μBH_1:\mu_A>\mu_B at 5%5\%, then H1:μA≠μBH_1:\mu_A\neq\mu_B.

A question asks whether the mean of one group is "different from" the other. Which alternative hypothesis do you use?

Interpreting results and limits

A significant result is evidence of an effect, not proof, and it says nothing about how large the effect is.

Compare pp with the given significance level: the same pp (for example 0.06770.0677) can be significant at 10%10\% but not at 5%5\%.

  • Expected frequencies of 55 or less make a χ2\chi^2 test unreliable, so combine categories.
  • The tt-test needs normal populations with equal variances.
  • A larger sample makes a real difference easier to detect.

Do not use a two-tailed test when only one direction was predicted in advance, and never change the level after seeing the result.

24681012140.10.20.30.40.5xydf = 2df = 4df = 6
Chi-squared curves for 2, 4 and 6 degrees of freedom. Large values in the right tail give small p-values and evidence against H₀.

Chi-squared test

Needs:
All expected frequencies above 5
Unreliable when:
An expected frequency is 5 or less

t-test

Needs:
Normal data, equal variances
Unreliable when:
Skewed data or different variances

Why might a χ2\chi^2 test be unreliable?

Try an exam question

A χ2\chi^2 test for independence is carried out on a 3×43\times4 contingency table at the 5%5\% significance level. The GDC gives p=0.032p=0.032. (a) State the hypotheses and the degrees of freedom. (b) State the conclusion in context, for a table of exam grade and revision method.

[4 marks]

That's the notes covered.

Carry on to the next subtopic.

Try a question

Write down the number of degrees of freedom for the test.

1 mark, marked against the mark scheme

Revision notes