Correlation and regression AI SL
Correlation tells you how closely two sets of paired data follow a pattern, and regression turns a straight-line pattern into an equation you can use for prediction. On this course the calculator finds every coefficient and every line, so the marks are for entering the pairs correctly, describing the strength and direction in words, and judging whether a prediction can be trusted. Start with correlation, then Spearman's rank, then the regression line.
Formulas at a glance
The booklet gives the form of the regression line, , and the range , but the values of , and come from the calculator. Spearman's formula is not in the booklet, because the examination expects the calculator to find the rank coefficient.
Regression line of on
In the bookletRange of Pearson's correlation coefficient
In the bookletCheck on a computed regression line
Line passes through
Not in the bookletWhich method to use
Decide first whether the question is about how two variables are related, about ranks, or about predicting a value. The calculator does the arithmetic in every case, so the skill is choosing the right output and saying what it means.
| The question has | Use | Notes |
|---|---|---|
| Pairs of data, and asks how strongly two variables are related in a straight line | Enter the pairs in two lists and run linear regression with diagnostics on. Read | Pearson's is only meaningful when the relationship is roughly linear |
| A value of or , and asks you to describe the correlation | Strength from : 0 to 0.5 weak, 0.5 to 0.8 moderate, 0.8 to 1 strong. Direction from the sign | Always give both strength and direction, and refer to the context |
| Ranks, scores from judges, or a curved relationship that always rises or always falls | Spearman's rank: rank each variable, using the mean rank for ties, then find of the ranks with the calculator | Spearman's is less affected by outliers than Pearson's |
| A prediction of from a given | Find the regression line with the calculator, then substitute | Use the unrounded values of and from the calculator |
| A prediction at an -value outside the range of the data | It is extrapolation. Make the prediction if asked, then comment that it may not be reliable | The pattern may not continue outside the data |
| A prediction of from a given | Do not rearrange the line of on to predict . Say that the prediction may not be reliable | The line of on is built for predicting |
| The mean point, or a regression line with one value missing | The regression line passes through . Substitute the mean point into | This gives from , or from |
| A question about whether one variable causes the other | Correlation does not imply causation. Suggest a third variable that could affect both | A strong shows association only |
Section 1 of 3 SL4.4
Correlation
Pearson's product-moment correlation coefficient measures how closely bivariate data follow a straight line, and it always satisfies . The sign gives the direction of the correlation and the size of gives its strength, with found using technology. The topic covers describing correlation in words and why correlation does not prove cause.
Reading the coefficient
Positive correlation
As increases, tends to increase too - points trend upward left to right, giving a positive gradient and .
Negative correlation
As increases, tends to decrease - points trend downward left to right, giving a negative gradient and .
No correlation
The points show no clear upward or downward trend - is close to zero, and fitting a line wouldn't be meaningful.
Range of Pearson's correlation coefficient: (in the booklet). The value of itself comes from the calculator.
Key terms
What is bivariate data?
Bivariate data are pairs of values recorded for each item in the study, one for each of two variables. Plotting the pairs on a scatter diagram shows whether the variables are related.
e.g. The height and shoe size of each of 12 students gives 12 pairs of values .
What do positive and negative correlation mean?
With positive correlation tends to increase as increases, and . With negative correlation tends to decrease as increases, and .
e.g. Hours of revision and test mark would probably show positive correlation, while the age of a car and its value would probably show negative correlation.
How do you describe the strength of a correlation?
The closer is to , the more closely the points lie on a straight line and the stronger the correlation. A value of close to means weak or no linear correlation.
e.g. is a strong negative correlation, while is a very weak positive correlation.
What does a correlation coefficient of zero tell you?
It tells you there is no linear correlation, but the variables can still be related in a non-linear way. A scatter diagram helps to check for this.
e.g. For the points with and , even though is completely determined by .
Worked example, step by step
The question Calculator needed [5 marks]
A sports scientist records the weekly training time, hours, and the time, minutes, taken to ride a 20 km route for eight club cyclists.
: 4, 6, 7, 9, 10, 12, 13, 15
: 58, 52, 55, 50, 53, 45, 47, 41
(a) Find the value of Pearson's product-moment correlation coefficient, .
(b) Describe the correlation between and .
(c) The scientist concludes that more training causes faster ride times. Comment on this conclusion.
Worked solution: worked example
Answer: (a) (b) strong negative correlation (c) correlation does not imply causation, so the data do not show that training causes faster times: another variable such as experience could affect both.
Step 1 - Enter the pairs.
Enter the -values in one list and the -values in a second list, in the same order. Both lists must have eight values. Check that the calculator will show (on some models, switch diagnostics on first).
Why? Each -value must be matched with its own -value. A swapped or missing value changes every output.
Step 2 - Run linear regression and read r.
Run the linear regression on the two lists. The calculator gives , to 3 significant figures. A1 - Calculator value of (unrounded) A1 - to 3 significant figures
Why? The correlation coefficient comes with the regression output, because both come from the same pairs. Use the value written , not .
Step 3 - Describe the correlation.
The value of is , which is between 0.8 and 1, so the correlation is strong. The sign is negative, so as increases, decreases. There is a strong negative correlation between training time and ride time. A1 - Strong A1 - Negative
Why? Strength comes from : 0 to 0.5 weak, 0.5 to 0.8 moderate, 0.8 to 1 strong. Direction comes from the sign. A full description gives both.
Step 4 - Comment on the conclusion.
Correlation does not imply causation. The data show that cyclists who train more tend to ride faster, but there could be another cause. For example, more experienced cyclists might both train more and ride faster, so the training time may not be what makes them quicker. R1 - Correlation does not imply causation, with another possible cause named
Why? A strong only shows association. To earn the reasoning mark, say that correlation is not causation and name another variable that could explain the pattern.
Step 5 - Check that a straight line is sensible.
A scatter diagram of these data shows the points falling steadily from the upper left to the lower right, close to a straight line, so Pearson's is a sensible measure here.
Why? Pearson's measures only a linear relationship. For a curved pattern a value of near 0 would not mean there is no relationship.
A1 Calculator value of (unrounded)
A1 to 3 significant figures
A1 Strong
A1 Negative
R1 Correlation does not imply causation, with another possible cause named
Now you try: enter your answers to be marked
These are real practice questions. Type your answer in each box and press Mark it. The worked solution and mark scheme appear straight away, and your first attempt is the one that counts. Use the keyboard for powers, roots and trig, and the working box for your notes.
Worked solution: practice question 1
| 1 | 2 | 3 | 4 | 5 | |
| 3 | 5 | 4 | 7 | 8 |
Worked solution: practice question 2
State the sign of .
Worked solution: practice question 3
Your score so far: 0 out of 7 marks
Calculator steps: Make a scatter diagram, Linear regression (line of best fit) and r
Common mistakes
- Claiming causation from correlation. A strong shows association, not cause and effect - always consider whether a confounding factor could explain the relationship instead.
- Confusing with . Some GDC output screens display both - always quote the value the question actually asks for, since is always positive and reads differently.
- Ignoring outlier effects. A single extreme point can pull noticeably toward zero even when the rest of the data is tightly linear - don't describe the correlation from alone without a glance at the scatter diagram.
Section 2 of 3 SL4.10
Spearman's rank
Spearman's rank correlation coefficient measures how well the ranks of two variables agree, on a scale from to . Replace each value with its rank, then find on a GDC. Use it instead of Pearson's when the relationship is consistently increasing or decreasing but not linear, or when outliers are present.
The formula
Spearman's rank coefficient
Not in the booklet. The examination expects the calculator, which finds from the two lists of ranks. To check by hand, rank both variables, find the difference between each pair of ranks, then apply the formula.
Reading the value
Interpreted exactly like Pearson's : close to is a strong positive monotonic relationship, close to strong negative, near little or no monotonic relationship.
Key terms
What is a rank?
A rank is a position in order, where the smallest value gets rank . Both variables must be ranked in the same direction.
e.g. The values have ranks when ranked from smallest to largest.
How do you rank tied values?
Tied values each get the mean of the ranks they would have taken. This keeps the total of the ranks correct.
e.g. In , the two sixes would take ranks and , so each gets rank , giving ranks .
What do the sign and size of tell you?
A positive value means that high ranks in one variable go with high ranks in the other, and a negative value means they go with low ranks. The closer to or , the stronger the agreement, and a value near means little agreement.
e.g. A value of shows strong negative agreement, so the highest ranks of one variable go with the lowest ranks of the other.
What is a monotonic relationship?
A monotonic relationship is one where one variable consistently increases, or consistently decreases, as the other increases. It does not have to be a straight line.
e.g. The pairs always increase but lie on a curve, so the ranks agree perfectly and , while Pearson's is less than .
Worked example, step by step
The question Calculator needed [6 marks]
Two critics each score eight short films out of 100.
Critic A: 72, 65, 88, 65, 90, 54, 79, 83
Critic B: 70, 64, 85, 60, 92, 66, 75, 80
(a) Write down the rank of each film for each critic, giving rank 1 to the lowest score.
(b) Find Spearman's rank correlation coefficient, .
(c) Describe the relationship between the critics' scores.
Worked solution: worked example
Answer: (a) critic A: 4, 2.5, 7, 2.5, 8, 1, 5, 6 and critic B: 4, 2, 7, 1, 8, 3, 5, 6 (b) (c) a strong positive relationship.
Step 1 - Rank critic A, sharing tied ranks.
Put the scores in order: 54, 65, 65, 72, 79, 83, 88, 90. The two scores of 65 would take ranks 2 and 3, so each gets the mean rank . The ranks for critic A, in the order of the films, are A1 - Ranks for critic A, with the tied ranks both
Why? Tied scores each get the mean of the ranks they would have taken. Keep the ranks in the original order of the films, so that each film's two ranks can be paired.
Step 2 - Rank critic B.
In order: 60, 64, 66, 70, 75, 80, 85, 92. There are no ties, so the ranks for critic B, in the order of the films, are A1 - Ranks for critic B
Why? Rank both variables in the same direction, smallest to largest. A mixed direction would turn a positive relationship into a negative one.
Step 3 - Find the correlation of the ranks.
Enter the ranks of critic A in one list and the ranks of critic B in a second list. Run the linear regression on these two lists and read . It is , to 3 significant figures. A1 - Calculator value of from the lists of ranks (unrounded) A1 - to 3 significant figures
Why? Spearman's is the ordinary correlation coefficient of the ranks. The calculator has no separate Spearman key, and the syllabus says to find it using technology. Use the lists of ranks, not the lists of scores.
Step 4 - Describe the relationship.
The value is between 0.8 and 1, so the relationship is strong, and it is positive. The critics' scores have a strong positive relationship: a film that one critic ranks highly tends to be ranked highly by the other. A1 - Strong A1 - Positive
Why? Strength and direction are read from in the same way as for Pearson's , and a complete answer gives both.
Step 5 - Compare with the raw scores.
Pearson's calculated from the original scores is , which is a different number. It measures how close the scores are to a straight line, while measures whether the order agrees.
Why? Spearman's coefficient works for any relationship that consistently rises or consistently falls, and it is less sensitive to outliers than Pearson's .
A1 Ranks for critic A, with the tied ranks both
A1 Ranks for critic B
A1 Calculator value of from the lists of ranks (unrounded)
A1 to 3 significant figures
A1 Strong
A1 Positive
Now you try: enter your answers to be marked
| 4 | 9 | 2 | 7 | 5 | 8 | |
| 55 | 74 | 49 | 78 | 64 | 70 |
Worked solution: practice question 1
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
| 2 | 3 | 5 | 9 | 17 | 33 | 65 | 129 |
Worked solution: practice question 2
| 5 | 34 |
| 8 | 29 |
| 8 | 41 |
| 11 | 41 |
| 14 | 47 |
| 14 | 55 |
| 17 | 50 |
| 20 | 62 |
| 23 | 62 |
| 26 | 70 |
Worked solution: practice question 3
Your score so far: 0 out of 11 marks
Calculator steps: Spearman's rank correlation coefficient
Common mistakes
- Ranking the wrong direction. Rank 1 can be the largest or the smallest value, as long as both variables use the same direction - a mixed convention reverses the sign of .
- Forgetting to average tied ranks. When two data items are equal, both should get the mean of the ranks they'd otherwise occupy, not two different whole-number ranks.
- Treating and Pearson's as interchangeable. detects any monotonic trend (including curved ones), while only detects a linear one - quoting the wrong coefficient for what the question describes loses marks.
Section 3 of 3 SL4.4
Regression line
The regression line of on , written , is the line that best fits the scatter of bivariate data, and it passes through the mean point . Use it to predict for a given , and interpret the gradient and intercept in context. Your GDC finds the equation, so the skill lies in using and interpreting it.
Key terms
What does the gradient of a regression line mean?
The gradient is the predicted change in for each increase of in . Always describe it using the units and context of the data.
e.g. If predicts a test score from hours of study, each extra hour of study is linked with more marks.
What does the intercept of a regression line mean?
The intercept is the predicted value of when . It is only meaningful when makes sense in the context.
e.g. For , the intercept predicts a score of marks for someone who did no study.
What is the mean point?
The mean point is , made from the mean of the -values and the mean of the -values. The regression line always passes through it.
e.g. If the regression line is and , then .
What is the difference between interpolation and extrapolation?
Interpolation predicts for an -value inside the range of the data, and extrapolation predicts outside that range. Extrapolation is less reliable and should come with a comment.
e.g. For data with from to , a prediction at is interpolation, but a prediction at is extrapolation.
Worked example, step by step
The question Calculator needed [7 marks]
A letting agent records the distance, km, of each of nine flats from the city centre and its monthly rent, dollars.
: 1, 2, 3, 4, 6, 8, 9, 11, 12
: 1450, 1395, 1310, 1290, 1170, 1110, 990, 945, 880
(a) Find the equation of the regression line of on .
(b) Interpret the gradient of the line in this context.
(c) Estimate the monthly rent of a flat 7 km from the city centre. Say whether the estimate is likely to be reliable.
Worked solution: worked example
Answer: (a) (b) the rent falls by about $50.9 for each extra kilometre from the centre (c) about $1130 per month, which is likely to be reliable because 7 km is inside the range of the data and the correlation is strong.
Step 1 - Enter the data and run the regression.
Enter the distances in one list and the rents in another, then run linear regression to find the line of on . The calculator gives and , and also .
Why? The rent depends on the distance , so this is the regression of on . Keep the full values from the calculator for later calculations.
Step 2 - Write the equation.
with both values to 3 significant figures. A1 - A1 -
Why? The equation is , with the gradient and the -intercept. The calculator returns and , so there is nothing to work out by hand.
Step 3 - Interpret the gradient.
The gradient is . For each extra kilometre from the city centre, the monthly rent is predicted to fall by about $50.9. A1 - The rent falls by about $50.9 for each extra kilometre
Why? Say what the gradient means in the units and context of the data: change in for each increase of 1 in . The sign tells you the direction.
Step 4 - Estimate the rent at 7 km.
Substitute into the line: . The estimated rent is about $1130 per month, to 3 significant figures. M1 - Substitute into their equation A1 - About $1130
Why? Using the unrounded and from the calculator gives the most accurate answer. The rounded line gives , which agrees with to 3 significant figures.
Step 5 - Judge the reliability.
The distances in the data run from 1 km to 12 km, so 7 km is inside the range. This is interpolation, and shows a very strong correlation, so the estimate is likely to be reliable. A flat 30 km away would be extrapolation: the line would give , a negative rent, which cannot be right. R1 - 7 km is inside the range of the data (interpolation) and is strong A1 - So the estimate is reliable
Why? Predictions inside the range of the data are more reliable than those outside it. Outside the range the pattern may not continue, so extrapolation should always come with a comment.
A1
A1
A1 The rent falls by about $50.9 for each extra kilometre
M1 Substitute into their equation
A1 About $1130
R1 7 km is inside the range of the data (interpolation) and is strong
A1 So the estimate is reliable
Now you try: enter your answers to be marked
Worked solution: practice question 1
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
| 42 | 48 | 55 | 58 | 65 | 70 | 74 | 84 |
Worked solution: practice question 2
Worked solution: practice question 3
Your score so far: 0 out of 9 marks
Calculator steps: Linear regression (line of best fit) and r
Common mistakes
- Extrapolating without comment. Using the regression line to predict far outside the data range and treating the answer as equally reliable as an interpolated one - always flag extrapolation as less trustworthy.
- Predicting from using the on line. The on regression line is built to predict . Rearranging it to predict gives a prediction that may not be reliable.
- Forgetting the mean-point property. When a question gives or alongside a partial equation, missing that the line must pass through loses an easy substitution mark.
Using your GDC
The exact key presses for the TI-84 Plus CE, Casio fx-CG50, Casio fx-CG100 and TI-Nspire CX, with what the screen shows. Pick your calculator.
Make a scatter diagram
Used in: Correlation
How to make a scatter diagram on a TI-84 Plus CE
Scatter plot from two lists (STAT PLOT) | |
If L1 and L2 already hold data, press stat, choose 4:ClrList, then press 2nd 1 (L1) , 2nd 2 (L2) and enter to empty them. |
ClrList L1,L2 |
Press stat, choose 1:Edit and press enter. Type the x-values into L1, pressing enter after each: 2, 3, 5, 6, 8, 9, 11, 12. Press ▶ to move to L2 and type the y-values in the same order: 31, 38, 40, 52, 55, 63, 60, 74. The two lists must have the same number of values. |
L1 L2 L3 2 31 --- 3 38 --- 5 40 --- 6 52 --- 8 55 --- 9 63 --- 11 60 --- |
Press 2nd Y= (STAT PLOT), choose 1:Plot1 and press enter. Highlight On and press enter. Check that Type is the first icon (scatter plot), Xlist is L1 and Ylist is L2. If not, move to the item, press enter to choose the icon, or type the list name with 2nd 1 (L1) or 2nd 2 (L2). |
Plot1 On Off Type: scatter (first icon) Xlist:L1 Ylist:L2 |
Press zoom and choose 9:ZoomStat. The calculator sets the window to fit the data and draws the scatter plot. Press trace and ◀ ▶ to move from point to point and read each pair of values. The points rise from the lower left to the upper right: as x increases, y increases. |
|
When you have finished, press 2nd Y= (STAT PLOT) and choose 4:PlotsOff. A plot left on makes the next function graph fail with an error.
The full guide: Make a scatter diagram
Linear regression (line of best fit) and r
Used in: Correlation, Regression line
How to find a line of best fit and r on a TI-84 Plus CE
Turn on r (once) | |
Press mode, use ▼ to reach STAT DIAGNOSTICS, move to ON with ▶ and press enter. Then press 2nd mode (QUIT). With diagnostics off, the correlation coefficient is not shown. This setting stays on until you reset the calculator. |
|
Enter the data and run LinReg(ax+b) | |
Press stat and choose 1:Edit. Clear any old values: move up to the L1 heading, press clear then enter, and do the same for L2. |
|
Type the -values into L1, pressing enter after each: 3, 5, 6, 8, 9, 11, 12, 14. Press ▶ to move to L2 and type the -values, pressing enter after each: 41, 48, 47, 58, 60, 69, 66, 77. Both lists must have the same number of values. |
L1 = 3, 5, 6, 8, 9, 11, 12, 14 L2 = 41, 48, 47, 58, 60, 69, 66, 77 |
Press stat, move to CALC with ▶, and choose 4:LinReg(ax+b). With the Stat Wizards on, a screen asks for Xlist and Ylist: set Xlist to L1 and Ylist to L2 (press 2nd 1 for L1 and 2nd 2 for L2), then move to Calculate and press enter. If the Stat Wizards are off, type |
LinReg(ax+b) y=ax+b a=3.2346939 b=30.7551020 r²=0.9678131 r=0.9837749 |
Read a (the gradient), b (the -intercept) and r. and , both to 3 significant figures. |
|
Predict a value from the line | |
Before you run LinReg, move to Store RegEQ on the wizard screen, press vars, then ▶ to Y-VARS and choose 1:Function then 1:Y1. The full-accuracy equation is then saved in Y1. On the home screen type when , to 3 significant figures. |
Y1(10) 63.1020408 |
If r does not appear, diagnostics are off: turn STAT DIAGNOSTICS on in the mode screen and run LinReg again. Use the full values of a and b, not rounded ones, when you predict.
The full guide: Linear regression (line of best fit) and r
Spearman's rank correlation coefficient
Used in: Spearman's rank
How to find Spearman's rank correlation coefficient on a TI-84 Plus CE
Rank the data, then linear regression on the ranks | |
Rank each variable by hand first, as in Spearman's rank. Then press stat and choose 1:Edit.... Type the values in L1 and the values in L2, pressing enter after each. Type the rank of each value in L3 and the rank of each value in L4, in the same order as the data. |
L1 L2 L3 L4 12 64 7 5 5 50 2 2 9 71 5 7 15 80 8 8 7 58 3 3 11 62 6 4 3 41 1 1 8 66 4 6 |
The correlation coefficient is only shown when diagnostics are on. Press mode, use ▼ to move to STAT DIAGNOSTICS, press ▶ to highlight ON and press enter. Press 2nd mode (QUIT) to leave the screen. |
STAT DIAGNOSTICS: OFF [ON] |
Press stat, press ▶ to reach CALC and choose 4:LinReg(ax+b). With the Stat Wizards on, a screen asks for each value: set Xlist to L3 (2nd 3) and Ylist to L4 (2nd 4), leave FreqList and Store RegEQ empty, and choose Calculate. If the wizards are off, type |
LinReg(ax+b) Xlist:L3 Ylist:L4 FreqList: Store RegEQ: Calculate |
The result shows a, b, r² and r. Because the two lists hold ranks, r is Spearman's coefficient. to 3 significant figures. |
LinReg y=ax+b a=0.8095238 b=0.8571429 r²=0.6553288 r=0.8095238 |
Read r from the rank lists, not from L1 and L2. The same command on the raw data gives Pearson's r, which is a different number.
The full guide: Spearman's rank correlation coefficient
See the full list of GDC guides for every calculator task.
Syllabus content covered
| Code | Syllabus content |
|---|---|
| SL4.4 | Linear correlation of bivariate data. Pearson's product-moment correlation coefficient, , found using technology. Scatter diagrams; lines of best fit, by eye, passing through the mean point. Equation of the regression line of on , found using technology, and its use for prediction. Interpret the meaning of the parameters, and , in a linear regression . Awareness of the dangers of extrapolation, and that correlation does not imply causation. |
| SL4.10 | Spearman's rank correlation coefficient, , found using technology; if data items are equal, ranks should be averaged. Awareness of the appropriateness and limitations of Pearson's product-moment correlation coefficient and Spearman's rank correlation coefficient, and the effect of outliers on each. |
Official IB source: Mathematics: applications and interpretation subject brief (PDF, ibo.org).
Quick questions
What does Pearson's correlation coefficient r measure?
measures the strength and direction of a linear relationship between two variables. It ranges from (perfect negative) to (perfect positive), with values near showing little or no linear relationship. It is calculated using technology, not by hand.
What is the formula for Spearman's rank correlation coefficient?
, where is the difference between the ranks of each pair and is the number of pairs. In examinations it is normally found using technology instead.
What does the regression line of y on x predict?
, found by technology, predicts from a given value. It should not be rearranged to predict from , because a prediction of made this way may not be reliable.
Does a strong correlation mean one variable causes the other?
No. A strong shows association, not cause and effect. A confounding factor could explain the relationship instead, so correlation alone never proves causation.
How is Spearman's rank different from Pearson's r?
Pearson's measures the strength of a linear relationship in the raw data. Spearman's rank works on the ranks of the data instead, so it measures any monotonic relationship (consistently increasing or decreasing, not necessarily in a straight line) and is less affected by outliers.
Why is extrapolation unreliable?
The regression line is only fitted to the range of -values in the data. Outside that range the linear pattern may not continue, so predictions there (extrapolation) are far less trustworthy than predictions inside the range (interpolation).
Can the correlation coefficient be greater than 1?
No. The value of always lies between and inclusive, so a result outside this interval means an error has been made.
What does mean?
The ranks of the two variables agree perfectly, so the order of one variable is exactly the order of the other. It does not mean the points lie on a straight line.
How do I get the regression line from my GDC?
Enter the -values and -values as two lists, then choose linear regression in the statistics menu. The GDC gives the values of and in .
How do I describe a correlation in an exam answer?
Give both the direction and the strength, and refer to the context of the variables. For example, "there is a strong positive linear correlation between hours of revision and test mark".
Ready to practise properly?
Practice questions on every section, marked instantly like the real exam.