Skip to main content
Mathematics LibreTexts

15.2: Linear Regression Analysis

  • Page ID
    105882
  • \( \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}\)

    Consider the following data set that contains information about a sample of ten 2016 Subaru Outback offered for sale:

    Vehicle

    Mileage (x1000miles)

    Price (x$1000)

    1

    11

    29

    2

    13

    29

    3

    13

    28

    4

    21

    27

    5

    36

    26

    6

    44

    26

    7

    48

    24

    8

    49

    22

    9

    60

    22

    10

    61

    21

    Let’s see what kind of questions we can answer using the linear regression analysis.

    1. Is there an association between the two variables?

    To see if there is an association and whether it is positive or negative, we need to construct a scatterplot – this can be easily done by hand or with technology. From the context it is clear that the price of a vehicle depends on the miles and not the other way around, so the mileage is the input variable on the horizontal axis, and the price is the output variable on the vertical axis. The scatter plot below summarizes the data regarding the mileage as the input variable and the price as the output variable:

    clipboard_e642b8b0a889644f77554b41b4ee5284a.png

    From the scatterplot it can be observed that there is a negative association since the increase in mileage is associated with the decrease in value.

    1. Find the slope, the y-intercept, and the coefficient of determination of the linear regression line.

    For that we are going to fill out the template table:

    \(x\)

    \(y\)

    \(x-\bar{x}\)

    \((x-\bar{x})^2\)

    \(y-\bar{y}\)

    \((y-\bar{y})^2\)

    \((x-\bar{x})(y-\bar{y})\)

    11

    29

    -24.6

    605.16

    3.6

    12.96

    -88.56

    13

    29

    -22.6

    510.76

    3.6

    12.96

    -81.36

    13

    28

    -22.6

    510.76

    2.6

    6.76

    -58.76

    21

    27

    -14.6

    213.16

    1.6

    2.56

    -23.36

    36

    26

    0.4

    0.16

    0.6

    0.36

    0.24

    44

    26

    8.4

    70.56

    0.6

    0.36

    5.04

    48

    24

    12.4

    153.76

    -1.4

    1.96

    -17.36

    49

    22

    13.4

    179.56

    -3.4

    11.56

    -45.56

    60

    22

    24.4

    595.36

    -3.4

    11.56

    -82.96

    61

    21

    25.4

    645.16

    -4.4

    19.36

    -111.76

    \(\bar{x}=35.6\)

    \(\bar{y}=25.4\)

    \(S_{xx}=\)

    \(3484.4\)

    \(S_{yy}=\)

    \(80.4\)

    \(S_{xy}=-504.4\)

    Now that we have the entire table complete, we can find the equation of the linear regression line.

    \(m=\frac{S_{xy}}{S_{xx}}=-\frac{504.4}{3484.4}=-0.145\)

    \(b=\bar{y}-m\bar{x}=25.4-(-0.145)\cdot35.6=30.553\)

    \(y=mx+b \rightarrow y=-0.145\cdot x+30.553\)

    We can also find the coefficient of determination using the formula

    \(r^2=\frac{S_{xy}^2}{S_{xx}S_{yy}}=\frac{(-504.4)^2}{3484.4\cdot80.4}=0.908\)

    Next, we can interpret the results:

     

    Units

    Interpretation

    \(m=-0.145\)

    $/mile

    depreciation rate is 14.5c/mile

    \(b=30.553\)

    $1000

    the price of a new car is $30553

    \(r^2=0.902\)

    n/a

    linear relation is strong

    Now that we confirmed the strong relation and found the equation that estimates the relation between the two variables, we can answer the next question.

    1. Estimate
      1. the price of a car with 27500 miles.

    \(y=-0.145\cdot27.5+30.553=26.565\)

    The units of the output variable in the equation are 1000$, so

    \(26.565\) is equivalent to \($26566\)

    Thus, the price of a 2016 Subaru Outback with 27500 miles is $26566.

    1. the mileage of a car whose price is $25000.

    Solve:

    \(25=-0.145x+30.553\)

    \(x=38.297\)

    The units of the input variable in the equation are 1000 miles, so

    \(38.297\) is equivalent to \(38297\) miles

    Thus, the expected mileage of a 2016 Subaru Outback that cost $25000 is 38297 miles.

    We just learned how to find and interpret the linear regression line and the coefficient of determination and use it in applications.


    15.2: Linear Regression Analysis is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?