From Paired Measurements to a Prediction
A regression task begins with paired observations: each recorded predictor value belongs with a response value measured on the same unit. For example, a researcher might record both the number of hours a student studied and that student's quiz score. Once the roles of the variables are clear, a least-squares regression line summarizes the linear relationship in the observed data and can be used to calculate a predicted response for a chosen predictor value.
The calculation is only one part of a useful answer. A complete prediction names the input value, states the predicted response with its units, and explains what the result means in context. It also makes clear that the line gives a prediction, not a guarantee about an individual outcome.
What to Check Before Calculating
A least-squares line is calculated from paired observations, not from two unrelated lists. Each pair must describe the same observational unit, such as one student or one day. Both variables must be quantitative, and the predictor values must vary; if every \(x\) value is identical, there is no slope to calculate.
The line describes a linear pattern in the data. It can be calculated even when a linear pattern is a poor description, but in that case its predictions may be unhelpful. For a prediction to be useful, the requested \(x\) value should also be meaningful in the setting and lie within the range represented by the observed predictor values. These checks concern the suitability of the description and prediction; they do not turn an observational association into evidence that changing \(x\) causes a change in \(y\).
For paired data \((x_i,y_i)\), the least-squares slope and intercept can be calculated from the sample means and the sums of deviations:
The slope measures the change in predicted response for a one-unit increase in the predictor. Its units are response units per predictor unit. The intercept is the predicted response at \(x=0\); that value may be mathematically defined even when zero is outside the relevant range or has no useful meaning in context.
Worked Example: Fitting a Line and Predicting a Quiz Score
In a hypothetical class exercise, five students report their study time and receive quiz scores. Let \(x\) be study time in hours and \(y\) be quiz score in points. The paired observations are:
| Study time, \(x\) (hours) | Quiz score, \(y\) (points) |
|---|---|
| 1 | 52 |
| 2 | 55 |
| 3 | 61 |
| 4 | 64 |
| 5 | 68 |
Each row is one student, so the measurements are paired. Study time and score are quantitative, and the predictor values vary. They show an increasing pattern over the observed range, making a straight-line summary plausible for this small example. The predictor values range from 1 to 5 hours.
Calculate the means. The mean study time is \(\bar{x}=(1+2+3+4+5)/5=3\) hours. The mean score is \(\bar{y}=(52+55+61+64+68)/5=60\) points.
Calculate the slope. The numerator is the sum of the products of the paired deviations; the denominator is the sum of squared predictor deviations:
The slope is \(4.1\) quiz points per additional hour of study. This is a description of the fitted line, not a claim that an extra hour causes every student's score to rise by exactly 4.1 points.
Calculate the intercept.
The fitted line is \(\hat{y}=47.7+4.1x\), with the response measured in quiz-score points. The intercept says the line predicts 47.7 points at zero study hours. Since zero is just outside the observed range, this value is not needed for the requested prediction and should not be given a broader interpretation.
Make a prediction. For a student who studied 3.5 hours, substitute \(x=3.5\):
The line predicts a quiz score of about 62.1 points for 3.5 hours of study. This is a predicted score from the fitted relationship, not a guaranteed score for any particular student.
Interpreting the Prediction and Its Coefficients
The fitted equation is not just a recipe for arithmetic. Its coefficients say how the line relates the two variables in the units used to collect the data. A slope of \(2.2\), for example, means that the predicted response changes by 2.2 response units for each one-unit increase in \(x\). A slope does not describe the change between every pair of observed individuals; it describes the change in the line's predictions.
The following identity explains why a slope can also be used to compare two predictions. Starting with the fitted line at two predictor values, subtract the first prediction from the second:
The intercept cancels, so the difference in predicted responses equals the slope multiplied by the difference in predictor values. This is why the slope's units are response units per predictor unit, and why it is important to state the size of the predictor change when describing a comparison.
Worked Example: Interpreting a Slope in Daily Sales
In a hypothetical set of paired observations on four days, a cafe records the afternoon temperature \(x\), in degrees Celsius, and the number of cold drinks sold \(y\). The observations are \((18,34)\), \((20,39)\), \((22,41)\), and \((24,48)\). Both variables are quantitative and measured for the same days. The temperatures vary from 18 to 24 degrees, and the listed sales increase across that range, so a line is a reasonable summary for this illustration.
The means are \(\bar{x}=(18+20+22+24)/4=21\) degrees and \(\bar{y}=(34+39+41+48)/4=40.5\) drinks. The products of paired deviations add to \((−3)(−6.5)+(−1)(−1.5)+(1)(0.5)+(3)(7.5)=44\). The squared predictor deviations add to \(9+1+1+9=20\). Therefore,
The fitted line is \(\hat{y}=-5.7+2.2x\). Its slope means that the predicted number of cold drinks sold is 2.2 higher for each one-degree Celsius increase in afternoon temperature, according to this fitted line. For a five-degree difference, the predicted difference is \(2.2(5)=11\) drinks. This describes an association in the hypothetical data; it does not establish that temperature alone causes the difference in sales.
The intercept is the line's predicted sales at \(0\) degrees Celsius, but zero is outside the observed temperature range of 18 to 24 degrees. In this example, the slope is useful for describing the observed trend; the intercept at zero should not be treated as a meaningful prediction about the cafe.
Carrying Out a Complete Regression Task
A clear solution follows the same sequence each time: identify which variable plays each role, fit the line, interpret the coefficients in units, and then evaluate the requested input. A final sentence should report the prediction in the setting's language. This sequence reduces the chance of getting the arithmetic right but answering a different question from the one asked.
State what \(x\) measures and what \(y\) measures, including their units. Check that each pair comes from the same observational unit.
Confirm that the variables are quantitative, the \(x\) values vary, and the observed pattern can reasonably be summarized as linear. Compare the requested \(x\) with the observed range.
Use the paired observations to calculate \(b_1\) and \(b_0\). Write \(\hat{y}=b_0+b_1x\), then explain the slope and intercept with context and units.
Insert the requested predictor value, show the arithmetic, and state the predicted response in context. Do not present it as an observed or guaranteed outcome.
Worked Example: Using a Fitted Line for a Delivery Prediction
Suppose a hypothetical analysis of paired deliveries reports the fitted line \(\hat{y}=12+3.5x\), where \(x\) is route distance in kilometres and \(y\) is delivery time in minutes. The line was fitted to routes between 2 and 10 kilometres. Here distance is the predictor and delivery time is the response. The reported slope is 3.5 minutes per kilometre; the intercept is 12 minutes.
A dispatcher asks for the predicted delivery time for a route of 6 kilometres. Since 6 is within the observed distance range, it is an in-range prediction. Substitute \(x=6\) into the fitted equation:
The line predicts a delivery time of 33 minutes for a 6-kilometre route. The slope means that the line's predicted time increases by 3.5 minutes for each additional kilometre. The intercept is the line's predicted time at zero kilometres, but the observations covered routes from 2 to 10 kilometres, so the intercept need not describe an actual delivery at zero distance.
This is a prediction from an observed association. It does not mean that every 6-kilometre delivery takes 33 minutes, and it does not show that distance alone causes delivery time to change. Traffic, stops, and other features of a route may also matter.
Common Mistakes
- Reversing predictor and response. A regression line predicts \(y\) from \(x\). Swapping the variable roles changes the question and generally gives a different line.
- Forgetting units. A slope of 2.2 is incomplete unless its units are stated, such as 2.2 drinks per degree Celsius.
- Calling the prediction an observed outcome. The value \(\hat{y}\) comes from the fitted equation. It is not the response actually measured for a particular individual.
- Giving the intercept an automatic real-world meaning. It is the fitted response at \(x=0\), but zero may be outside the data range or irrelevant to the setting.
- Assuming association proves cause. A fitted slope summarizes an observed relationship. By itself, it does not establish that changing the predictor causes the response to change.
A common incorrect argument is, “The slope is 3.5 minutes per kilometre, so a 6-kilometre route must take \(3.5(6)=21\) minutes.” That calculation uses the slope as if it were the whole prediction and silently assumes the intercept is zero. The fitted line is \(\hat{y}=12+3.5x\), so the correct calculation includes the intercept: \(12+3.5(6)=33\) minutes.
Check Your Understanding
Use the ideas in this tutorial to answer the following questions.
- A data set records the number of practice sessions and the time to complete a task for each participant. Which variable would be the predictor if the question is how completion time varies with practice?
- A fitted line predicts \(48\) points for a student who studied 4 hours. Explain why this does not mean that every student who studies 4 hours will score exactly 48 points.
- A fitted line is \(\hat{y}=7+1.8x\), where \(x\) is distance in kilometres and \(y\) is time in minutes. What are the units and contextual interpretation of the slope?
- For the line in question 3, calculate the predicted time at \(x=5\) kilometres and state the result with units.
- A fitted line has an intercept of \(-5\), but the observed predictor values range from 10 to 25. Why might the intercept have little practical meaning?