Linear regression for predicting continuous outcomes
Explain how linear regression is used to predict continuous outcomes
In this lesson
- Explaining the relationship between the independent (predictor) and dependent (response) variables
- Explaining the significance of the slope and the intercept in the regression equation
- Explaining how well a model fits the data, using r²
LearnPredicting a number
LearnSlope and intercept
LearnFinding the line, and measuring the fit
LabFit a line
Move the line yourself, then compare it with the least-squares line. Watch the residuals, SSres, SStot and r², and try the data sets where a straight line works badly.
Fare = 28.40 + 0.000 × Distance
SSres = 3,473 · SStot = 3,473 · r² = 1 − SSres ÷ SStot = 0.000
A flat line at the mean of the data: SS_res equals SS_tot, so r² is about 0. The line explains none of the variation.
Move the sliders yourself, fit the least-squares line on at least three data sets, and make a prediction to complete this activity.
CheckQuick check
A model predicts a phone's battery life in hours from the hours of video watched per day: battery life = 31.0 − 2.4 × video hours. What does −2.4 tell you?
CheckQuick check
A regression model of a gym's daily visitors has SSres = 300 and SStot = 1200. What is r²?
CheckRegression or classification?
Is each outcome continuous (a regression problem) or a category (a classification problem)?
- The number of minutes a delivery will take
- Whether a bank transaction is fraudulent
- Tomorrow's maximum temperature in °C
- Which of five species a photographed bird belongs to
- The amount of electricity a building will use next month, in kWh
ExamWorked exam answer
A hospital has records of 2000 patients, each with the patient's age and the number of days they stayed in hospital after an operation. Explain how linear regression could be used to predict how long a new patient will stay.
[4]ReviewMistakes examiners see
Using linear regression to predict a category. It predicts a number on a continuous scale.
Describing the slope as “how steep the line is” without saying what it means in context: the change in Y for each one-unit increase in X, in the units of the problem.
Treating r² as the percentage of predictions that are correct. It is the proportion of the variation in Y that the model explains.
Predictions are most reliable inside the range of X values in the training data. Predicting outside it (extrapolation) assumes the straight line continues, which it may not.
Exam practiceExam-style questions
5 questions · 12 marks. Answer each one first, then mark it yourself against the markscheme. Your answers are saved in this browser only.
A city's bike-sharing scheme recorded the number of bikes hired and the midday temperature on each of 365 days, when temperatures ranged from 2 °C to 31 °C. A linear regression model fitted to these records is hires = 420 + 38 × temperature, with r² = 0.58.
Identify the independent variable and the dependent variable in this model.
Explain the significance of the values 38 and 420 in the model.
Calculate the number of hires the model predicts on a day when the midday temperature is 25 °C.
Explain what r² = 0.58 tells the scheme's managers about the model.
The managers want a better model. Suggest one additional independent variable and how it would change the model.
0 of 5 questions marked. Mark every question to see your total.
Exam-style questions written for Praxis IB in the format of the 2027 specimen papers. They are not IB past-paper questions.