Calculating Correlation & Regression (AA HL)

When two variables might be linked, a scatter diagram shows the pattern and Pearson's correlation coefficient rr puts a number on how strong and in which direction that linear pattern runs. This topic covers finding rr and r2r^2 on your GDC, fitting the regression lines of yy on xx and of xx on yy, and using those lines carefully to predict one variable from the other - without falling into the traps of extrapolation or mistaking correlation for causation.

What the syllabus says

This topic maps onto two points in the official IB Analysis & Approaches syllabus.

CodeSyllabus content
SL4.4Linear correlation of bivariate data - technology should be used to calculate Pearson's product-moment correlation coefficient rr, although hand calculation may enhance understanding. Scatter diagrams; lines of best fit passing through the mean point. Distinction between correlation and causation - correlation does not imply causation. Equation of the regression line of yy on xx, found using technology, used for prediction, interpreting the parameters aa and bb in y=ax+by=ax+b, and awareness of the dangers of extrapolation.
SL4.10Equation of the regression line of xx on yy, and its use for prediction - with awareness that this line cannot always reliably be used to predict yy from a given xx value.

Official IB source: Mathematics: analysis and approaches subject brief (PDF, ibo.org).

These are core AA SL syllabus points that are also examinable at AA HL.

Key terms

Five words worth knowing cold before you touch the formulas below - each with a worked example showing exactly what it means.

What is Pearson's correlation coefficient rr?

rr is a number between −1-1 and 11 that measures how closely a set of bivariate data follows a straight line. A value near 11 means a strong positive linear relationship, near −1-1 means a strong negative one, and near 00 means little or no linear relationship. It says nothing about non-linear patterns.

e.g. For (1,2),(2,4),(3,6),(4,8)(1,2), (2,4), (3,6), (4,8) every point lies exactly on y=2xy=2x, so r=1r = 1.

What is the regression line of yy on xx?

The regression line of yy on xx is the straight line y=ax+by=ax+b that best fits the data by minimising the vertical distances from each point to the line. It always passes through the mean point (x¯,y¯)(\bar x, \bar y), and is the line used when predicting yy from a given value of xx.

e.g. If x¯=5\bar x = 5, y¯=20\bar y = 20 and the gradient is 22, then b=y¯−ax¯=20−2(5)=10b = \bar y - a\bar x = 20 - 2(5) = 10, giving y=2x+10y = 2x+10.

What is the regression line of xx on yy?

The regression line of xx on yy is a different straight line, found by minimising the horizontal distances instead of the vertical ones. It's used only for predicting xx from a given value of yy - swapping the yy on xx line around algebraically does not give the same line.

e.g. If the yy on xx gradient is 22 and r=0.9r=0.9, the xx on yy gradient is r2/2=0.81/2=0.405r^2/2 = 0.81/2 = 0.405, not 1/21/2.

What is r2r^2?

r2r^2, the coefficient of determination, is the square of the correlation coefficient. It gives the proportion of the variation in one variable that can be explained by a linear relationship with the other, usually expressed as a percentage.

e.g. If r=0.95r = 0.95, then r2=0.9025r^2 = 0.9025, so 90.25%90.25\% of the variation in yy is explained by xx.

What's the difference between interpolation and extrapolation?

Interpolation is using a regression line to predict a value that falls within the range of the original data, which is generally reliable. Extrapolation is predicting outside that range, which is risky because there's no evidence the linear pattern continues beyond the data collected.

e.g. If xx ranges from 1010 to 5050 in the data, predicting at x=30x=30 is interpolation; predicting at x=100x=100 is extrapolation.

Key formulas

A handful of formulas cover this topic, and every one of them is normally evaluated on your GDC rather than substituted into by hand. The tables below summarise them - the explanations underneath go into more depth.

Formula reference

Pearson's rr and both regression line equations are given in the formula booklet - the coefficient of determination r2r^2 is not listed separately since it's simply rr squared.

FormulaUsed forBooklet?
r=SxySxxSyyr = \dfrac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}Pearson's product-moment correlation coefficientYes
y−y¯=SxySxx(x−x¯)y-\bar y = \dfrac{S_{xy}}{S_{xx}}(x-\bar x)Regression line of yy on xxYes
x−x¯=SxySyy(y−y¯)x-\bar x = \dfrac{S_{xy}}{S_{yy}}(y-\bar y)Regression line of xx on yyYes
r2r^2Coefficient of determinationNot in booklet - square the value of r

Regression line of y on x vs x on y

These are two genuinely different lines, and mixing them up is one of the most common ways marks are lost on this topic.

FeatureLine of y on xLine of x on y
Minimisesvertical distances to the linehorizontal distances to the line
Formy=ax+by=ax+bx=cy+dx=cy+d
Use it to predictyy from a given xxxx from a given yy
Passes through(x¯,y¯)(\bar x,\bar y)(x¯,y¯)(\bar x,\bar y)
Gradient relationshipproduct of the two gradients =r2=r^2

Correlation and its strength

Sign of r

−1≤r≤1-1 \le r \le 1

Positive rr: as xx increases, yy tends to increase. Negative rr: as xx increases, yy tends to decrease.

In the formula booklet

Strength of r

|r| near 1=strong|r|\text{ near }1 = \text{strong}

|r||r| close to 11 means a strong linear relationship; |r||r| close to 00 means a weak or absent one.

Not in the formula booklet - interpretation only

Correlation vs causation

r≠proof of causer \ne \text{proof of cause}

A strong rr shows association, not that one variable causes the other - a third, confounding variable could explain both.

Not in the formula booklet - conceptual point

Using the regression line for prediction

Interpolation

xmin≤x≤xmaxx_{\min} \le x \le x_{\max}

Predicting within the range of the collected data - generally reliable, since the line is supported by nearby data.

Not in the formula booklet - definition

Extrapolation

x<xmin or x>xmaxx < x_{\min}\text{ or }x > x_{\max}

Predicting outside the data range - the linear pattern is not guaranteed to continue, so the prediction may be unreliable.

Not in the formula booklet - definition

Interpreting the gradient

y=ax+by = ax+b

In context, aa is the change in yy per unit increase in xx, and bb is the value of yy predicted when x=0x=0 (if that makes sense in context).

Not in the formula booklet - interpretation

Worked examples

Two full exam-style questions, marked exactly like the real thing. Try each one yourself before checking the worked solution.

1
Medium
Calc
[7 marks]

A farmer records fertiliser applied xx (kg/hectare) and crop yield yy (tonnes/hectare) for 6 plots:

xx203550658095
yy3.13.94.65.46.06.7

(a) Calculate the Pearson's product-moment correlation coefficient r,r, and interpret its strength and direction.

(b) Find the equation of the regression line of yy on x.x.

(c) Predict the yield for 7070 kg/hectare of fertiliser.

Worked solution

(a) r≈0.999,r \approx 0.999, a very strong positive linear correlation. M1
A1
R1

(b) y≈0.0478x+2.20.y \approx 0.0478x + 2.20. M1 A1

(c) y≈0.0478(70)+2.20y \approx 0.0478(70) + 2.20 M1
≈5.55\approx 5.55 tonnes/hectare. A1

M1 Attempt at computing r using the GDC A1 Correct value r≈0.999r\approx0.999 R1 Reasoning identifying the correlation as very strong and positive M1 Attempt at linear regression of y on x using the GDC A1 Correct equation y≈0.0478x+2.20y\approx0.0478x+2.20 M1 Substituting x=70 into the regression equation from (b) A1 Correct value ≈5.55\approx5.55 tonnes/hectare
2
Hard
No calc
[5 marks]

Data on xx and yy gives the regression line y=3x+1y = 3x + 1 with r=0.95r = 0.95.
New variables are defined: u=2x+1u = 2x + 1 and v=y−4v = y - 4.

(a) Express the regression line of vv on uu in the form v=au+bv = au + b.

(b) State the value of the correlation coefficient between uu and vv.

(c) State the gradient of the regression line of uu on vv.

Worked solution

(a) v=y−4=(3x+1)−4=3x−3v = y-4 = (3x+1)-4 = 3x-3 M1 Substituting y=3x+1y=3x+1 into v=y−4v=y-4 to express vv in terms of xx. Since x=(u−1)/2x=(u-1)/2, v=3⋅u−12−3=1.5u−1.5−3v = 3\cdot\dfrac{u-1}{2}-3 = 1.5u-1.5-3 M1 Substitute xx in terms of uu. =1.5u−4.5=1.5u-4.5 A1 Correct simplified equation v=1.5u−4.5v=1.5u-4.5.

(b) Linear transformations do not change |r||r|, so r=0.95r = 0.95. A1 Correct value r=0.95r=0.95, stated directly from the fact that linear transformations preserve |r||r|.

(c) a2=r2/a1=0.9025/1.5=0.602a_2 = r^2/a_1 = 0.9025/1.5 = 0.602 (3 significant figures) A1 Correct value ≈0.602\approx0.602 for the gradient of uu on vv, using a2=r2/a1a_2=r^2/a_1.

M1 Method - substituting the transformation into the given regression line A1 Accuracy - correct equation or numerical value

Common mistakes

The four slip-ups that account for most of the marks lost on this topic - worth reading before you start practising, not just after you get one wrong.

  • Confusing the sign of rr with its strength. r=−0.9r=-0.9 is a stronger relationship than r=0.3r=0.3 - the sign only tells you the direction, the magnitude |r||r| tells you the strength.
  • Using the yy on xx line to predict xx from yy. Rearranging y=ax+by=ax+b algebraically does not give the true xx on yy regression line - you need to run the regression the other way on your GDC.
  • Extrapolating with confidence. A prediction far outside the range of xx-values in the data is unreliable, even with a strong rr - always check whether you're interpolating or extrapolating before trusting the answer.
  • Treating a strong rr as proof of causation. A high correlation shows association, not that one variable causes the other - a confounding factor could be driving both.

Using your GDC

Every step below is a real button sequence, not a vague "use your calculator" hint - covering the TI-84 Plus, TI-Nspire, and Casio fx-9860/fx-CG50. Pick your model to filter down to just the steps that apply to you.

Show steps for:
Linear regression (line of best fit) and r

Core AA skill - gives the regression line and the correlation coefficient in one step.

  1. Enter x-values in one list and y-values in another.
  2. Turn on DiagnosticOn once (2nd → CATALOG) so r appears; then STAT → CALC → 4:LinReg(ax+b), set Xlist and Ylist, Calculate.TI-84
  3. Calculator page → menu → Statistics → Stat Calculations → Linear Regression (mx+b).Nspire
  4. Statistics menu → CALC (F2) → REG (F3) → X (linear); r shows automatically.Casio
  5. Read a (gradient), b (intercept), r (correlation) and r² (coefficient of determination).
  6. Use the equation to predict - but only within the data range (interpolation).

Tip: r near ±1 means a strong linear fit; near 0 means weak. r² is the proportion of variation explained.

One-variable statistics (mean, median, standard deviation)

Instant summary statistics from a list - no formulas to compute by hand. Useful for finding x¯\bar x and y¯\bar y before working with the regression line.

  1. Enter the data into a list.
  2. STAT → Edit → type values into L1. Then STAT → CALC → 1:1-Var Stats, choose L1, Calculate.TI-84
  3. Add a Lists & Spreadsheet page, name a column and enter data; then a Calculator page → menu → Statistics → Stat Calculations → One-Variable Statistics.Nspire
  4. Statistics menu → enter data in List 1 → CALC (F2) → 1-VAR.Casio
  5. Read x̄ (mean), Sx (sample sd) or σx (population sd), and the five-number summary (min, Q1, median, Q3, max).
  6. For frequency data, put values in one list and frequencies in another and set the frequency list.

Tip: Sx vs σx: use σx (population) for a complete data set, Sx (sample) for a sample. IB usually wants σx.

See the full GDC guide for more calculator models and topics.

Quick questions

The questions students on this topic ask most often.

What does a correlation coefficient close to 1 or -1 mean?

A value of rr close to 11 or −1-1 means the points lie close to a straight line - close to 11 is a strong positive relationship (as xx increases, yy increases), close to −1-1 is a strong negative relationship (as xx increases, yy decreases). A value near 00 means little or no linear relationship.

What's the difference between the regression line of y on x and the line of x on y?

The line of yy on xx minimises the vertical distances from the points to the line, and is used to predict yy from a given xx. The line of xx on yy minimises the horizontal distances instead, and is used to predict xx from a given yy. They are two different lines unless the correlation is perfect.

Why can't I use the y on x line to predict x from a y value?

The yy on xx line was built to minimise vertical errors when predicting yy, not horizontal errors when predicting xx - rearranging it algebraically gives a different, less accurate line than the true xx on yy regression. Use the xx on yy line whenever you're predicting xx from yy.

Is Pearson's r formula given in the exam formula booklet?

Yes - the formula for rr, and the equations of both regression lines, are in the topic 4 section of the AA formula booklet. In practice you'll almost always find rr and the regression line directly from your GDC rather than substituting into the formula by hand.

Ready to practise properly?

Correlation & regression questions, marked instantly like the real exam.