Statistics, correlation and hypothesis tests
🖨 Print a self-study sheet Why print?
Does revising with music help or hurt? Are boys and girls equally likely to choose science? Is this dice fair? Each question can be argued forever with opinions. Statistics lets us argue with data instead: we collect evidence, measure how surprising it would be if nothing interesting were going on, and decide.
In IB Maths AI the GDC does most of the arithmetic in these tests. Your job is to set up the right test, state the hypotheses clearly, and write a conclusion that a non-mathematician could understand. That is a skill worth practising, because it is where most marks are won and lost.
Correlation and regression
Pearson's correlation coefficient measures the strength of a linear relationship, from to . Values near mean strong, near weak or no linear relationship. The regression line of on , found with the GDC, is used to predict from , but only within the range of the data (interpolation), and only when the correlation is reasonably strong.
Spearman's rank correlation coefficient measures how well the relationship is monotonic: whether one variable tends to increase as the other does, even if not in a straight line. Rank each variable, then find Pearson's of the ranks with the GDC. When there are no tied ranks, this equals where is the difference between the two ranks of each item.
The \chi^2 test for independence
To test whether two categorical variables are related, arrange the data in a contingency table.
- H_0: the variables are independent. H_1: the variables are not independent.
- Expected frequency of each cell =\dfrac{\text{row total}\times\text{column total}}{\text{grand total}}. Each should be at least 5; if not, combine rows or columns.
- Degrees of freedom =(\text{rows}-1)(\text{columns}-1).
- The GDC gives \chi^2_{\text{calc}}=\sum\dfrac{(f_o-f_e)^2}{f_e} and the p-value.
- If the p-value is less than the significance level (often 5\%), reject H_0.
The \chi^2 goodness-of-fit test
To test whether data fit a claimed distribution, compare observed and expected frequencies in each category. H_0: the data follow the distribution. Here the degrees of freedom are (\text{number of categories})-1 when the expected frequencies come straight from the claim.
The t-test
A t-test compares the means of two independent groups, using raw data entered in the GDC. H_0: the population means are equal; H_1: they are different, or one is greater, depending on the question. Read the p-value from the GDC and compare it with the significance level.
Similar exercises
For a set of data with 10\le x\le40, the regression line of y on x is y=2.4x+15 and r=0.92.
a) Estimate y when x=10.
b) Comment on whether this estimate is reliable.
What you need: substitute, then check the strength and the range.
Show solution
a) Substituting gives y=2.4(10)+15=39.
b) The correlation r=0.92 is strong and positive, and x=10 lies within the range of the data, so this is interpolation.
So the estimate y=39 is reliable.
Answer. a) 39; b) reliable.
Two variables are ranked for four items, giving ranks 1,2,3,4 and 4,3,1,2. Calculate Spearman's rank correlation coefficient.
What you need: r_s=1-\dfrac{6\sum d^2}{n(n^2-1)}.
Show solution
The rank differences are 1-4=-3, 2-3=-1, 3-1=2 and 4-2=2, so \sum d^2=9+1+4+4=18.
Then r_s=1-\dfrac{6(18)}{4(16-1)}=1-\dfrac{108}{60}=-0.8.
So r_s=-0.8: a fairly strong negative association between the rankings.
Answer. r_s=-0.8.
In a contingency table with grand total 200, a cell is in a row with total 80 and a column with total 50. Find its expected frequency.
What you need: \dfrac{\text{row total}\times\text{column total}}{\text{grand total}}.
Show solution
The expected frequency is what we would expect in that cell if the variables were unrelated. If the two variables were independent, the cell's expected frequency would be \dfrac{80\times50}{200}=20.
So the expected frequency is 20.
Answer. 20.
How many degrees of freedom does a \chi^2 test for independence have for a table with 3 rows and 4 columns?
What you need: (r-1)(c-1).
Show solution
Once the row and column totals are known, only (\text{rows}-1)(\text{columns}-1) cells can be chosen freely. The number of degrees of freedom is (\text{rows}-1)(\text{columns}-1)=(3-1)(4-1)=2\times3.
So the test has 6 degrees of freedom.
Answer. 6.
A researcher wants to test whether the type of phone a student owns is related to the student's age group. State the null and alternative hypotheses.
What you need: H_0 for independence says the variables are independent.
Show solution
For a \chi^2 test for independence, the null hypothesis says there is no relationship, and the alternative says there is one.
So H_0: type of phone is independent of age group; H_1: type of phone is not independent of age group.
Answer. H_0: independent; H_1: not independent.
Applied exercises
A shop manager expects the same number of customers each weekday. Over a week she counts 42, 38, 35, 45 and 40 customers from Monday to Friday. Test her expectation at the 5\% level.
What you need: expected frequency \dfrac{200}{5}=40; 4 degrees of freedom.
Show solution
H_0: customers are equally likely on each weekday; H_1: they are not. The total is 200, so each expected frequency is 40, and the degrees of freedom are 5-1=4.
\chi^2_{\text{calc}}=\dfrac{2^2+(-2)^2+(-5)^2+5^2+0^2}{40}=\dfrac{58}{40}=1.45, and the GDC gives p-value \approx0.835.
Since 0.835>0.05, we do not reject H_0. So the data are consistent with the same number of customers each weekday.
Answer. \chi^2=1.45, p-value \approx0.835; do not reject H_0.
Two teaching methods are compared. With method A, 45 of 60 students passed; with method B, 30 of 60 passed. Test at the 5\% level whether passing is independent of the method.
What you need: a 2\times2 table; expected frequencies 37.5 and 22.5; 1 degree of freedom.
Show solution
H_0: passing is independent of the method; H_1: it is not. Out of 120 students, 75 passed and 45 failed, so for each method the expected frequencies are \dfrac{60\times75}{120}=37.5 passes and \dfrac{60\times45}{120}=22.5 fails; df =(2-1)(2-1)=1.
\chi^2_{\text{calc}}=\dfrac{7.5^2}{37.5}\times2+\dfrac{7.5^2}{22.5}\times2=3+5=8, and the GDC gives p-value \approx0.00468.
Since 0.00468<0.05, we reject H_0. So there is evidence that passing depends on the method; method A has the higher pass rate.
Answer. \chi^2=8, p-value \approx0.00468; reject H_0.
A t-test comparing the mean reaction times of two groups gives a p-value of 0.18. At the 5\% level, what can be concluded?
What you need: compare 0.18 with 0.05.
Show solution
The p-value 0.18 is greater than 0.05, so we do not reject H_0.
This means there is not enough evidence that the mean reaction times of the two groups differ. It does not prove that they are equal; the sample may simply be too small to show a difference.
So we do not reject H_0.
Answer. Do not reject H_0; no significant evidence of a difference.
In a \chi^2 test for independence, one expected frequency is 3.2. Explain the problem and what should be done.
What you need: the condition on expected frequencies.
Show solution
The \chi^2 test is only reliable when every expected frequency is at least 5. A cell with expected frequency 3.2 makes the test statistic unreliable, because small expected values make \dfrac{(f_o-f_e)^2}{f_e} very large for small differences.
The usual remedy is to combine that row or column with a neighbouring one that makes sense in context, then recompute the expected frequencies and degrees of freedom, or to collect more data.
So the categories should be combined (or more data collected) before carrying out the test.
Answer. Combine categories or collect more data so that all expected frequencies are at least 5.
Marked like the Vietnamese graduation exam: Part I 0.25 points per question; Part II up to 1 point per question (1, 2, 3, 4 correct statements give 0.1, 0.25, 0.5, 1 point); Part III 0.5 points per question.
Part I. Multiple choice
r near 0 means a weak or no linear relationship.
(2-1)(3-1)=2.
\dfrac{60\times40}{120}=20.
0.012<0.05.
Part II. True or false
| a) The judges' rankings tend to be opposite. | ||
| b) The association is strong. | ||
| c) r_s can be greater than 1. | ||
| d) Spearman's coefficient uses ranks. |
-1\le r_s\le1.
Part III. Short answer
\dfrac{60\times30}{120}=15.
5-1=4.
Show answers and explanations
- Part I, question 1: B. r near 0 means a weak or no linear relationship.
- Part I, question 2: D. (2-1)(3-1)=2.
- Part I, question 3: A. \dfrac{60\times40}{120}=20.
- Part I, question 4: C. 0.012<0.05.
- Part II, question 1: a) True; b) True; c) False; d) True. -1\le r_s\le1.
- Part III, question 1: 15. \dfrac{60\times30}{120}=15.
- Part III, question 2: 4. 5-1=4.