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β1) and intercept (β0β0). We obtain the estimates, ˆβ1^β1 and ˆβ0^β0 by finding the values that minimize the sum of squared residuals ().

SSR=ni=1[yiˆyi]2=[yi(ˆβ0+ˆβ1xi)]2=[yi(ˆβ0ˆβ1xi]2SSR=ni=1[yi^yi]2=[yi(^β0+^β1xi)]2=[yi(^β0^β1xi]2

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

SSRˆβ1=2ni=1xi(yiˆβ0ˆβ1xi)SSRˆβ0=2ni=1(yiˆβ0ˆβ1xi)

Let’s begin by deriving ˆβ0.

SSRˆβ0=2ni=1(yiˆβ0ˆβ1xi)=0ni=1(yi+ˆβ0+ˆβ1xi)=0ni=1yi+nˆβ0+ˆβ1ni=1xi=0nˆβ0=ni=1yiˆβ1ni=1xiˆβ0=1n(ni=1yiˆβ1ni=1xi)ˆβ0=ˉyˆβ1ˉx

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

SSRˆβ1=2ni=1xi(yiˆβ0ˆβ1xi)=0ni=1xiyi+ˆβ0ni=1xi+ˆβ1ni=1x2i=0(Fill in ˆβ0)ni=1xiyi+(ˉyˆβ1ˉx)ni=1xi+ˆβ1ni=1x2i=0(ˉyˆβ1ˉx)ni=1xi+ˆβ1ni=1x2i=ni=1xiyiˉyni=1xiˆβ1ˉxni=1xi+ˆβ1ni=1x2i=ni=1xiyinˉyˉxˆβ1nˉx2+ˆβ1ni=1x2i=ni=1xiyiˆβ1ni=1x2iˆβ1nˉx2=ni=1xiyinˉyˉxˆβ1(ni=1x2inˉx2)=ni=1xiyinˉyˉxˆβ1=ni=1xiyinˉyˉxni=1x2inˉx2

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

xiyinˉyˉx=(xˉx)(yˉy)=(n1)Cov(x,y)

x2inˉx2(xˉx)2=(n1)s2x

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

Thus, applying () and (), we have

ˆβ1=ni=1xiyinˉyˉxni=1x2inˉx2=ni=1(xˉx)(yˉy)ni=1(xˉx)2=(n1)Cov(x,y)(n1)s2x=Cov(x,y)s2x

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)s2x=rsysxs2x=rsysx