Chapter 2 Simple Linear Regression

2.1 Getting started

Putting text here

2.2 Foundation

Putting text here

2.3 Inference

Putting text here

2.4 Prediction

2.5 Checking conditions

2.6 Partioning variability

2.7 Derivation for slope and intercept

This document contains the mathematical details for deriving the least-squares estimates for slope (β1) and intercept (β0). We obtain the estimates, β^1 and β^0 by finding the values that minimize the sum of squared residuals ().

SSR=i=1n[yiy^i]2=[yi(β^0+β^1xi)]2=[yi(β^0β^1xi]2

Recall that we can find the values of β^1 and β^0 that minimize () by taking the partial derivatives of () and setting them to 0. Thus, the values of β^1 and β^0 that minimize the respective partial derivative also minimize the sum of squared residuals. The partial derivatives are

SSRβ^1=2i=1nxi(yiβ^0β^1xi)SSRβ^0=2i=1n(yiβ^0β^1xi)

Let’s begin by deriving β^0.

SSRβ^0=2i=1n(yiβ^0β^1xi)=0i=1n(yi+β^0+β^1xi)=0i=1nyi+nβ^0+β^1i=1nxi=0nβ^0=i=1nyiβ^1i=1nxiβ^0=1n(i=1nyiβ^1i=1nxi)β^0=y¯β^1x¯

Now, we can derive β^1 using the β^0 we just derived

SSRβ^1=2i=1nxi(yiβ^0β^1xi)=0i=1nxiyi+β^0i=1nxi+β^1i=1nxi2=0(Fill in β^0)i=1nxiyi+(y¯β^1x¯)i=1nxi+β^1i=1nxi2=0(y¯β^1x¯)i=1nxi+β^1i=1nxi2=i=1nxiyiy¯i=1nxiβ^1x¯i=1nxi+β^1i=1nxi2=i=1nxiyiny¯x¯β^1nx¯2+β^1i=1nxi2=i=1nxiyiβ^1i=1nxi2β^1nx¯2=i=1nxiyiny¯x¯β^1(i=1nxi2nx¯2)=i=1nxiyiny¯x¯β^1=i=1nxiyiny¯x¯i=1nxi2nx¯2

To write β^1 in a form that’s more recognizable, we will use the following:

xiyiny¯x¯=(xx¯)(yy¯)=(n1)Cov(x,y)

xi2nx¯2(xx¯)2=(n1)sx2

where Cov(x,y) is the covariance of x and y, and sx2 is the sample variance of x (sx is the sample standard deviation).

Thus, applying () and (), we have

β^1=i=1nxiyiny¯x¯i=1nxi2nx¯2=i=1n(xx¯)(yy¯)i=1n(xx¯)2=(n1)Cov(x,y)(n1)sx2=Cov(x,y)sx2

The correlation between x and y is r=Cov(x,y)sxsy. Thus, Cov(x,y)=rsxsy. Plugging this into (), we have

β^1=Cov(x,y)sx2=rsysxsx2=rsysx