Back to homeMathematics · 1st Bach. Social Sciences · Change subject
Start for free
BAC1 ss · Mathematics
Statistics · Statistics

Regression line

You already have the covariance and the correlation coefficient: numbers that describe the relationship. Now it is time to build the tool that predicts: the regression line. There are two, depending on which variable you want to estimate from the other, and each one is fitted by minimising a different error.

Before you start, make sure you know: Point-slope equation of a line (4th ESO)
Before you start, make sure you know: Bivariate distributions (4th ESO)

The regression line of $Y$ on $X$

Scatter plot with the regression line of Y on X passing through the centre of gravity and minimising the squared residuals. (x̄, ȳ) passes through the centre; minimises the sum of squared residuals
Practice★★☆Not started
A group of 1st Bachillerato students has conducted a study on the relationship between the daily time (in hours) spent using a popular short-video social network ($X$)…

A group of 1st Bachillerato students has conducted a study on the relationship between the daily time (in hours) spent using a popular short-video social network ($X$) and the battery percentage remaining on their mobile at the end of the day ($Y$). The data obtained from 6 classmates are as follows:

Hours of use ($X$) 1.5 2 3 3.5 4 5
% Battery ($Y$) 75 68 50 45 32 20

a) Calculate the centre of gravity of the distribution $(\bar{x}, \bar{y})$.

b) Find the covariance $\sigma_{xy}$ and the linear correlation coefficient $r$. Interpret the result obtained regarding the sign and the strength of the relationship.

c) Determine the equation of the regression line of $Y$ on $X$.

d) If a student uses the social network for 2.5 hours, what battery percentage is estimated to remain? Is this prediction reliable? Justify your answer based on the coefficient of determination $r^2$.

1 2 3 4 5 6 20 40 60 80 100 Hours of use (X) % Battery (Y) 2,5 ? (x̄, ȳ) Actual data Regression Prediction
Solve
Practice★☆☆Not started
A study on study habits in Year 12 analyses the relationship between the number of weekly hours spent reading, $X$, and the mark obtained in the Spanish exam, $Y$. The…

A study on study habits in Year 12 analyses the relationship between the number of weekly hours spent reading, $X$, and the mark obtained in the Spanish exam, $Y$. The regression line of $Y$ on $X$ is:

$y = 0,65x + 3,2$

  1. a) Justify whether the correlation between both variables is positive or negative.
  2. b) If a student spends $8$ weekly hours reading, what mark is estimated for them in the exam?
Solve

The regression line of $X$ on $Y$

The two regression lines, of Y on X and of X on Y, both with a gradient of the same sign and intersecting at the centre of gravity. Y on X X on Y (x̄, ȳ)
Practice★★★Not started
The grades of 50 students in Economics ($X$) and Geography ($Y$) have a mean of 6,5 in both subjects. The variance in Economics is 4 and in Geography it is 2,25. It is…

The grades of 50 students in Economics ($X$) and Geography ($Y$) have a mean of 6,5 in both subjects. The variance in Economics is 4 and in Geography it is 2,25. It is known that the correlation coefficient is $r = 0,8$.

  1. a) If a student has obtained a 4 in Economics, estimate their grade in Geography.
  1. b) If another student has obtained a 9 in Geography, estimate their grade in Economics using the appropriate regression line.
  1. c) Compare both estimates and explain why the same line cannot be used for both cases if we want to minimize the mean squared error.
Solve
Practice★★☆Not started
In a study on sleep habits and academic performance, the following regression lines were obtained for the variables $X$ (daily hours of sleep) and $Y$ (average term…

In a study on sleep habits and academic performance, the following regression lines were obtained for the variables $X$ (daily hours of sleep) and $Y$ (average term mark):

Regression line of $Y$ on $X$: $y = 0,65x + 3,2$

Regression line of $X$ on $Y$: $x = 1,15y - 0,45$

a) Knowing that both lines intersect at the centre of gravity of the distribution, calculate the mean hours of sleep ($\bar{x}$) and the students' average mark ($\bar{y}$).

b) Calculate the linear correlation coefficient $r$ from the gradients of both lines.

c) State with reasoning whether the correlation is positive or negative and whether it is strong or weak.

X (Hours of sleep) Y (Average mark) 0 5 10 15 20 5 10 15 y = 0,65x + 3,2 x = 1,15y - 0,45 G(x̄, ȳ) x̄ ȳ
Solve

The residual: the error of a prediction

Diagram of the residual as the vertical distance between an observed data point and its corresponding predicted value on the line. actual data point yᵢ predicted ŷᵢ residual = vertical distance between the data point and the line
Practice★★☆Not started
An athletics coach analyses the relationship between the height of his athletes in cm ($X$) and their stride length in cm ($Y$). The data for 5 athletes are: (160, 110),…

An athletics coach analyses the relationship between the height of his athletes in cm ($X$) and their stride length in cm ($Y$). The data for 5 athletes are: (160, 110), (170, 120), (175, 125), (180, 132) and (190, 145).

a) Obtain the regression line of $Y$ on $X$.

b) What stride length would be expected for an athlete who is 185 cm tall?

c) Calculate the prediction error (residual) for the athlete who is 180 cm tall. The error is defined as the difference between the actual value and the value estimated by the line: $e = y_i - \hat{y}_i$.

d) If the correlation coefficient were $r = 0,98$, what could you state about the reliability of the coach's predictions?

Solve
Practice★★★Not started
In a contingency table relating level of education ($X$) and income ($Y$) for a sample, some data have been lost. We know the following parameters: $\bar{x} = 3$;…

In a contingency table relating level of education ($X$) and income ($Y$) for a sample, some data have been lost. We know the following parameters:

$\bar{x} = 3$; $\bar{y} = 2\,400$; $s_x^2 = 1,2$; $s_y^2 = 160\,000$ and the regression line of $Y$ on $X$ is $y = 300x + 1\,500$.

  1. Calculate the coefficient of determination $R^2$ and interpret the percentage of the variance in income that is explained by the level of education.

  2. If an individual has an education level of $X=5$ and their actual income is $3\,200$ €, calculate the prediction error (residual) made by the line.

1 2 3 4 5 6 1500 2000 2500 3000 3500 Level of education (X) Income (Y) y = 300x + 1500 Residual = 200 Centre of gravity (3, 2400) Prediction (5, 3000) Actual value (5, 3200)
Solve

Predicting with caution: interpolating and extrapolating

Regression line with a scatter plot illustrating an interpolation within the observed data range and an extrapolation outside it. observed data extrapolate (outside the range) within the range: reliable outside: not guaranteed
Practice★★☆Not started
A pet adoption centre wants to predict the time it takes for a dog to be adopted ($Y$, in days) based on its age ($X$, in years). They have collected data from 10 dogs…

A pet adoption centre wants to predict the time it takes for a dog to be adopted ($Y$, in days) based on its age ($X$, in years). They have collected data from 10 dogs and obtained a correlation of $r = 0,85$. The mean age is 4 years and the mean number of days until adoption is 25 days. The standard deviation of age is 2 years and that of the days is 10 days.

a) Find the equation of the regression line.

b) Estimate how long it will take for a 0.5-year-old puppy to be adopted.

c) Estimate how long it will take for a 12-year-old senior dog.

d) Of the two previous estimates, indicate which is more reliable and why, taking into account the range of the original data (ages between 1 and 8 years).

Solve
Practice★★★Not started
A sociologist analyses the relationship between weekly time spent watching television ($X$, in hours) and concentration ability in a specific test ($Y$, scale from 0 to…

A sociologist analyses the relationship between weekly time spent watching television ($X$, in hours) and concentration ability in a specific test ($Y$, scale from 0 to 100). Data from 10 teenagers yielded the following partial results:

$\sum x_i = 150$; $\sum y_i = 620$; $\sum x_i^2 = 2\,850$; $\sum y_i^2 = 41\,500$; $\sum x_iy_i = 8\,400$.

Find:

  1. The covariance $s_{xy}$ and the correlation coefficient $r$.

  2. The regression line of $Y$ on $X$.

  3. A student spends 40 hours per week watching television. Calculate their estimated score on the test. Analyse whether this estimate is an interpolation or an extrapolation and discuss its real validity in the context of the problem.

Solve

Lab: comparing a line and a parabola with a spreadsheet

A cooperative is studying the cost of an advertising campaign. These data are simulated for practice: t is the number of batches of adverts and s is the total cost, in hundreds of euros.

t 0 1 2 3 4
s 0,9 2,2 5,0 9,8 17,1

Before calculating, plot the points and make a prediction: does the cost of each additional batch seem constant or increasing?

  1. Write t in A1 and s in B1; place the five pairs in A2:B6. Create an XY scatter plot, not a chart that treats the quantities as category labels.

  2. Obtain a linear fit and a degree-2 polynomial fit using your spreadsheet's fitting/trendline tool. Display the equations and keep enough decimal places. Compare the coefficients with the calculation below.

  3. In C2 write =-1+4*A2 (linear prediction) and in D2 =1+A2^2 (quadratic); fill down to row 6. In E2 write =B2-C2 and in F2 =B2-D2: these are the residuals, observed minus predicted.

  4. In G2 write =E2^2, in H2 =F2^2 and in I2 =(B2-7)^2; fill down. Here 7 is the mean of the five costs. Add up each column; for example, =G2+G3+G4+G5+G6 avoids depending on the language of the functions.

The curvature can be seen by plotting the data together with both models:

Scatter plot of cost with a visual comparison between the linear fit and the parabolic fit. 04 batches 016Cost (hundreds of €) lineparabola

The scatter plot and the residuals favour the parabola over this interval. At $t=2{,}5$, it predicts $7{,}25$ hundred euros; this is interpolation. At $t=10$, it predicts $101$ hundred euros, but this is a distant extrapolation: neither the fit nor its $R^2$ guarantees that the cost structure will hold. Compare with a new data point before using the model to make decisions.

Interpolating a parabola through three points forces it to pass through them; a regression with more data minimises the residuals and, in general, does not pass through all of them. They are not the same procedure.

Summary

See all the exercises in this section