4.3: Building a Least Squares Model
- Page ID
- 236963
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\dsum}{\displaystyle\sum\limits} \)
\( \newcommand{\dint}{\displaystyle\int\limits} \)
\( \newcommand{\dlim}{\displaystyle\lim\limits} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\(\newcommand{\longvect}{\overrightarrow}\)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\ket}[1]{\left| #1 \right>}\)
\(\newcommand{\bra}[1]{\left< #1 \right|}\)
\(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
\(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
\(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
\(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
\(\newcommand{\expect}[1]{\langle #1 \rangle}\)
\(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)
- Use technology to write the equation of a least squares regression line for a set of bivariate data.
- Use a least squares regression line to solve problems.
- Distinguish between interpolation and extrapolation in making predictions.
Introduction
In Section 4.2, we focused on interpreting a least‑squares regression model once it had already been created. These models are built from sample data, and although no linear equation will fit every point in a scatterplot perfectly, a strong correlation allows us to use the model to make reasonable predictions.
In this section, we shift from using a regression model to constructing such a model with technology. By examining the structure of regression more closely, we will see how sample data lead to a specific equation and how that equation captures the overall trend in the relationship between two quantitative variables.
Using Technology to Find the Slope and y‑Intercept
We now focus on writing the equation of the least‑squares regression line from a set of data. Our goal is to determine the values of the \(y\)‑intercept \(a\) and slope \(b\) in the model
\(\hat{y}=a+bx\),
so that the sum of the squared residuals is minimized. This produces the line that best represents the linear trend in the data.
Although the slope and \(y\)‑intercept can be computed manually, the algebra involved is beyond the scope of this course. Instead, we will rely on technology to generate the regression equation and then use that equation to interpret relationships, make predictions, and solve problems.
Write the least squares regression equation for the line that best fits this simple set of bivariate data.
|
\(x\) |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
|---|---|---|---|---|---|---|---|
|
\(y\) |
2 |
4.5 |
9 |
11 |
13 |
18 |
19.5 |
Solution
We will find the \(y\)-intercept and slope with a graphing calculator using the steps below.
|
1. |
Press [STAT] and choose 1:Edit to type the x-values in L1 and the y-values in L2. |
|
|---|---|---|
|
2. |
Check to make sure the data are strongly correlated by displaying the data in a scatterplot. Press [2nd] [Y=] to access STAT PLOTS. Modify the options to show a scatterplot for the data as we have done before. Press [ZOOM] and 9:ZoomStat to automatically fit the window to the data. Return to Section 4.1 to review the steps of making a scatterplot if needed. |
|
|
3. |
Press [STAT] and use the right arrow to move to the CALC menu. |
|
|
4. |
Choose 8:LinReg(a+bx). This is the command we used previously to find the correlation coefficient. Note that 4:LinReg(ax+b) looks similar, but the equation is not the form we use in statistics. |
|
|
5. |
You will have one of the two screens shown here. If you have the top one, the blinking cursor is waiting for you to enter the names of the lists of data separated by a comma: L1,L2. Press [ENTER]. If you have the STAT WIZARD screen like the one on the bottom, choose L1 for Xlist and L2 for Ylist. You can leave the other options blank for now. Highlight Calculate and press [ENTER]. |
|
|
6. |
The value \(a\) is the \(y\)-intercept and the value \(b\) is the slope to match the statistical form of the line at the top. You can also see the correlation coefficient \(r\). The linear regression equation is \(\hat{y} \approx 2.054+2.982x\). |
|
|
7. |
To check how well this regression line fits the data, press [Y =] and type the regression equation into equation Y1. |
|
|
8. |
Press [GRAPH] to evaluate the fit of the linear model. Press [TRACE] to move to any data value so you can compare its value to the predicted value, \(\hat{y}\), shown by the line. |
|
|
Note: Instead of manually typing the regression equation in [Y =], you can paste it there. While in the [Y=] screen, press [VARS]. Choose 5:Statistics. Arrow over to EQ and select 1:RegEQ. |
Peter is testing the burning time of Brite‑n‑Glo candles. The table shows how long candles of different weights burn. He wants to know whether a linear model is appropriate and, if so, how to interpret the resulting regression equation.
|
Candle weight (oz.) |
Time (hours) |
|---|---|
|
2 |
15 |
|
3 |
20 |
|
4 |
35 |
|
5 |
36 |
|
10 |
80 |
|
16 |
100 |
|
22 |
120 |
|
26 |
180 |
Solution
The explanatory variable is candle weight, and the response variable is burning time. A scatterplot of the data shows a strong linear trend with only minor scatter, so it is reasonable to model the relationship using a least‑squares regression line.

Using a graphing calculator, the regression results and a graph of the regression line are as follows:

Peter can write the regression equation as
\(\widehat{\text{time}} \approx 5.93+6.12(\text{candle weight)}\).
The regression line fits the data well because the points lie close to the line.
The slope of the regression equation is 6.12. This means that, on average, each additional ounce of candle weight increases the burning time by about 6.12 hours.
The \(y\)‑intercept is 5.93. This represents the predicted burning time for a candle weighing 0 ounces. Because a candle cannot weigh zero ounces, this value does not have a practical interpretation, but it is still necessary for defining the regression line mathematically.
Ms. Fox collected data from her high school class by measuring each student’s height and then recording how many steps each student took to walk the length of a school hallway.
\[ \begin{array}{|c|c|c|} \hline \textbf{Student} & \textbf{Height (inches)} & \textbf{Number of steps} \\ \hline \text{A} & 64 & 51 \\ \hline \text{B} & 68 & 49 \\ \hline \text{C} & 61 & 56 \\ \hline \text{D} & 70 & 44 \\ \hline \text{E} & 63 & 54 \\ \hline \text{F} & 68 & 50 \\ \hline \text{G} & 70 & 49 \\ \hline \text{H} & 73 & 42 \\ \hline \text{I} & 71 & 44 \\ \hline \text{J} & 67 & 49 \\ \hline \text{K} & 66 & 48 \\ \hline \text{L} & 64 & 60 \\ \hline \text{M} & 68 & 55 \\ \hline \text{N} & 66 & 54 \\ \hline \text{O} & 68 & 46 \\ \hline \end{array} \nonumber \]
a. Predict the number of steps for a student who is 65 inches tall.
Solution
Using a graphing calculator, we treat height as the explanatory variable and number of steps as the response variable.

The regression equation is \(\widehat{\text{steps}}=133.05−1.24(\text{height})\).
Substituting 65 for height, \(\widehat{\text{steps}}=133.05−1.24(65) \approx 52.05\).
A student who is 65 inches tall is predicted to take about 52 steps to walk the hallway.
b. What does the slope tell you about height and number of steps?
Solution
The slope is –1.24. This means that for every additional inch of height, a student is predicted to take 1.24 fewer steps. Taller students generally take longer strides, so they need fewer steps to cover the same distance.
c. Find the residual for Student A.
Solution
Student A is 64 inches tall and took 51 steps. Substituting their height (64) into the regression equation, we can predict that Student A's number of steps as
\(\widehat{\text{steps}}=133.05−1.24(64) \approx 54\) steps.
The residual is
\(e= \text{steps}(y) - \widehat{\text{steps}}(\hat{y})=51−54=−3\).
The residual is negative, meaning the model over‑predicts Student A’s number of steps by 3.
d. Another student (not in the original data) took 47 steps. How tall do you think this student is?
Solution
To estimate the height, solve the regression equation for the value of height \(x\) that predicts \(\hat{y}=47\) steps:
\(\begin{align*} 47 &= 133.05 - 1.24x \\[6px] 1.24x &= 86.05 \\[6px] x &= \frac{86.05}{1.24} \\[6px] x &= 69.4 \end{align*}\)
A student who takes 47 steps is predicted to be 69.4 inches tall.
Interpolation and Extrapolation
Interpolation and extrapolation are two ways to use a regression model to predict hypothetical values of a response variable based on an explanatory variable.
Interpolation occurs when we make a prediction using an explanatory value within the range of the data used to create the regression line. Because the model is being applied to familiar territory—values similar to those already observed—interpolated predictions are generally more reliable.
In Example 4.3.3, we predicted the number of steps for a student who is 65 inches tall. This is interpolation because \(x=65\) lies between the observed heights of 61 inches and 73 inches. We are fairly confident of the trend between heights of 61 and 73 inches.
Extrapolation, on the other hand, occurs when we make a prediction using an explanatory value outside the range of the original data. These predictions are riskier because they assume that the trend observed in the sample continues beyond the values we actually measured. We don't know that they actually do.
For instance, using the model from Example 4.3.3 to predict the number of steps for a 40‑inch‑tall 3rd grader is extrapolation. The value \(x=40\) is far below the heights of the sampled high school students [61,73] that were used to write the regression equation. The model predicts \(\widehat{\text{steps}}=133.05−1.24(40) \approx 83\) steps, but we cannot be as confident that this is a good prediction.
The figure below illustrates this distinction clearly: interpolation stays within the data range, while extrapolation extends beyond it.

Interpolation is preferred because it is more likely to produce meaningful estimates. Extrapolation requires caution; the relationship between variables may change outside the observed range, and predictions can become unrealistic or misleading. When a model produces such unreasonable results, we call this an extrapolation error.
Section Summary
In this part of the chapter, we moved from interpreting a regression model to understanding how regression equations are created and evaluated. A least‑squares regression line models the linear relationship between two quantitative variables by choosing the slope and \(y\)‑intercept that minimize \(\sum(y−\hat{y})^2\), the sum of the squared residuals. Although the calculations behind this process are algebraically complex, technology allows us to generate the regression equation efficiently and use it to make predictions and solve problems.
We also distinguished between interpolation and extrapolation when using a regression model for prediction. Interpolation uses explanatory values within the range of the original data and typically produces reliable estimates. Extrapolation uses values outside that range and must be approached cautiously, as the observed trend may not continue beyond the data. Extreme extrapolation can lead to unrealistic or meaningless predictions, known as extrapolation errors.
Together, these ideas form the foundation for building, interpreting, and responsibly using linear regression models to analyze real‑world relationships.
Section 4.3 Review Questions
- The table shows the paired SAT math scores and GPAs for 7 students.
|
SAT math score, \(x \) |
595 |
520 |
715 |
405 |
680 |
490 |
565 |
|---|---|---|---|---|---|---|---|
|
GPA, \(y\) |
3.4 |
3.2 |
3.9 |
2.3 |
3.9 |
2.5 |
3.5 |
- Use technology to make a scatterplot of the data. Use SAT math score as the explanatory variable. Visually, does there appear to be a strong correlation?
- Use a calculator to write the least squares regression equation. Round all values to four decimal places.
- What is the value of the correlation coefficient? Explain how its value confirms your answer to part (a).
- Use the equation to predict the GPA for a student with an SAT score of 500. Round GPA to the nearest hundredth. Did you interpolate or extrapolate to make the prediction?
- Draw and complete a table like the one below. Fill in the predicted values and residuals for each student. Round each GPA to the nearest hundredth.
|
SAT math score, \(x \) |
595 |
520 |
715 |
405 |
680 |
490 |
565 |
|---|---|---|---|---|---|---|---|
|
GPA, \(y\) |
3.4 |
3.2 |
3.9 |
2.3 |
3.9 |
2.5 |
3.5 |
| predicted GPA, \(\hat{y}\) | |||||||
| residuals, \(y-\hat{y}\) |
- A school nurse wants to predict scores on a memory test from the number of times that a student exercises per week. Below are her observations from several students. Use technology to answer the questions below.
|
Student # |
Exercise (days per week) |
Memory Test Score |
|---|---|---|
|
1 |
0 |
15 |
|
2 |
2 |
3 |
|
3 |
2 |
7 |
|
4 |
1 |
11 |
|
5 |
3 |
5 |
|
6 |
1 |
8 |
|
7 |
2 |
10 |
|
8 |
0 |
13 |
|
9 |
3 |
2 |
|
10 |
3 |
4 |
|
11 |
4 |
2 |
|
12 |
1 |
8 |
|
13 |
1 |
10 |
|
14 |
1 |
12 |
|
15 |
2 |
8 |
- Use technology to make a scatterplot. Be sure choose the correct variables for the explanatory and response variables.
- Does this appear to be a linear relationship? Why or why not?
- Find the least squares regression equation used to model this data. Round all values to four decimal places.
- Predict the memory test score of a student who exercises 3 times per week. Round the score to the nearest whole number.
- What is the slope in this linear regression model, and what does this mean in this scenario?
- What is the y-intercept in this linear regression model? If it has meaning in this scenario, interpret its value.
- Draw the regression line on the scatterplot. Identify the student for which the model gives a residual value furthest from 0.
- Find the residual for Student #11.
- Predict the memory test score of a student who exercises every day of the week. Do you have concerns about making this prediction? Why or why not?
- James and Keisha kept track of the temperature and the number of cups of coffee sold over a 9-day period at their food truck. Their data are shown below.
|
Temperature \(^{o}F\) |
9 |
18 |
20 |
26 |
28 |
31 |
32 |
36 |
48 |
|---|---|---|---|---|---|---|---|---|---|
|
Cups of Coffee |
45 |
41 |
34 |
36 |
32 |
28 |
23 |
23 |
18 |
- Use technology to construct a scatterplot. Does there appear to be a positive, negative, or no correlation between the temperature and the number of cups of coffee sold?
- Based on the scatterplot, do there appear to be any outliers? If so, which points?
- Use technology to find the correlation coefficient.
- Use technology to write the regression equation to predict the number of cups of coffee sold. Round all values to two decimal places.
- Use the regression line from part d to predict the amount of coffee sold if the temperature is \(2\)2 degrees.
- Keisha would like to use the regression line to predict the amount of coffee sold if the temperature is \(-10\) degrees. Is this an appropriate use of the regression line? Why or why not?
- Identify and interpret the value of the slope in this scenario.
- Find the residual for the cups of coffee on the day when the temperature was \(48\) degrees.
- Anne is trying to find the elasticity coefficient of a Superball in a science experiment. She drops the ball from different heights and measures the maximum height of the ball after the bounce. The table below shows the data she collected.
|
Initial height (cm) |
Bounce height (cm) |
|---|---|
|
30 |
22 |
|
35 |
26 |
|
40 |
29 |
|
45 |
34 |
|
50 |
38 |
|
55 |
40 |
|
60 |
45 |
|
65 |
50 |
|
70 |
52 |
- Use technology to draw a scatter plot using initial height of the ball as the explanatory variable. Is there a strong correlation?
- Create the regression equation to predict bounce height. Round values to places.
- Identify and interpret the value of the slope in this scenario.
- Identify the value of the \(y\)-intercept. Interpret its value if there is meaning.
- Anne wants the ball to bounce 65 cm. From what height should she drop the ball? Do you have concerns about whether this is a reasonable answer? Why or why not?

