9.3: The Line of Best Fit
- Page ID
- 49069
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \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{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)In a previous section, we saw that an r value close to 1 may indicate a strong linear relationship between an explanatory variable and a response variable. In such situations, we may choose to use an equation of a line to summarize the relationship. We can then use a linear model to make predictions about the values of the response variable.
- Imagine a line that fits the data best. Which of the purple points, A, B, C, D, or E, does the line intersect? Sketch the line below.
- Imagine the line in your head continuing out to x=100. Estimate the y-coordinate of the point on the line where x is 100. Explain how you made your guess.
- Select the line below that corresponds to the choice you made in question 1. Use it’s equation to predict the y-coordinate of the point on the line where x is 100.
Line A. \(y=0.3x+1.5\)
Line B. \(y=0.3x+0.5\)
Line C. \(y=0.2x+1\)
Line D. \(y=0.15x+0.75\)
Line E. \(y=0.05x+1.25\)
- Why do you think this line fits the data best?
LSR Line
- The least squares regression line (LSR line) is a linear model that puts roughly half of your scatterplot data above the line and roughly half of your scatterplot data below the line. This line is also called the line of best fit as it is the line from which the points in the scatterplot deviate the least from. What do the values -2, 2, and 0 on the graph below represent?
- What do the values 4, 4, and 0 on the graph represent?
- Now drag the line by dragging the two red dots at this desmos graph. You can use the QR code below to access the desmos graph.
- What is the smallest you can make the sum of the squared error about the line?
- What do you think is true about the line with the smallest sum of squared errors?
For this bivariate set of data, the smallest sum of squared error about the line is 6. The equation of the line of best fit is \(\hat{y}=0.5 x+1.5\).
Residuals
The residual is the difference (or vertical distance) between the ACTUAL value of a data set \((y)\) for an \(x\)-value and the value that your line PREDICTED \((\hat{y})\) for that \(x\)-value.
- Let’s return to the original example. The line of best fit is approximately \(\hat{y}=0.2 x+1\) (the line that passes through point C). Let’s look at how much the data deviates from the linear model. The residual for the point (1,1) has been computed and entered in the table below. Complete the table in the same manner.
x
y
\(\hat{y}\)
\(y-\hat{y}\)
1
1
\(\hat{y}=0.2(1)+1=1.2\)
\(1-1.2=-0.2\)
2
3
5
1
6
2
9
5
10
2
- Here's one way to measure how well a line fits a data set:
- Square all the residuals.
- Add up those squares.
The smaller the result, the better the fit. Calculate the square of each residual and enter it in the table. The first squared residual has been computed in the table. Complete the table.
x |
Residual: \(y-\hat{y}\) |
Squared Residual |
1 |
\(-0.2\) |
\((-0.2)^2=0.04\) |
2 |
||
5 |
||
6 |
||
9 |
||
10 |
The sum squared residuals is _______.
Calculating and Interpreting Values in the Equation of the LSR Line
- Use the following steps to calculate the equation of the line of best fit:
- Open this file that contains randomly collected data comparing the number of cricket chirps and the temperature. Copy the data from the file by highlighting the data and clicking copy.
- Alternatively, you can access the data set using this QR code:
- Alternatively, you can access the data set using this QR code:
- Open https://www.desmos.com/calculator and paste the data into the first line by clicking paste.
- In the second line, calculate the linear correlation coefficient, \(r\), by typing in \(\operatorname{corr}\left(x_1, y_1\right)\).
r= __________
- Compute the sample means, \(\bar{x}=\operatorname{mean}(x 1)\) and \(\bar{y}=\operatorname{mean}(y 1)\), and sample standard deviations, \(s_x=\operatorname{stdev}(x 1) \text { and } s_y=\operatorname{stdev}(y 1)\).
\(\bar{x}=\) __________
\(\bar{y}=\) __________
\(S_x=\) __________
\(S_y=\) __________
- Calculate the slope, \(m=\frac{r \cdot s_y}{s_x}\), of the line of best fit.
- The slope of the line is the predicted change in y for every unit change in x. Interpret the slope of the equation of the line of best fit in context (the units of x are number of chirps, and the units of y are degrees fahrenheit).
- Calculate the y-intercept, \(b=\bar{y}-m \cdot \bar{x}\), for the line of best fit.
- The y-intercept of the line of best fit is the predicted y-value when the x-value is 0. Interpret the y-intercept in context.
- Write the equation you found. Use the line of best fit to predict the temperature near a cricket that chirps 24 times.
\(\hat{y}=\) ______________.
- Open this file that contains randomly collected data comparing the number of cricket chirps and the temperature. Copy the data from the file by highlighting the data and clicking copy.
- One of the crickets chirped 16 times and the temperature near it was 71.6 degrees Fahrenheit. Calculate the residual for this cricket.
- In desmos, type in y1~mx1+b to check your work.
\(\hat{y}=\) ______________