Lecture 2 SLR - 1
Lecture 2 SLR - 1
1 / 28
Outline:
2 / 28
Linear Regression
3 / 28
Linear Regression
4 / 28
The Linear Regression Model SW Section 4.1
5 / 28
The Population Linear Regression Model
Consider
Yi = β0 + β1 Xi + ui
for i = 1, . . . , n
▶ We have n observations, (Xi , Yi ), i = 1, .., n.
▶ X is the independent variable or regressor or right-hand-side variable
▶ Y is the dependent variable or left-hand-side variable
▶ β0 = intercept
▶ β1 = slope
▶ ui = the regression error
▶ The regression error consists of omitted factors. In general, these
omitted factors are other factors that influence Y , other than the variable
X . The regression error also includes error in the measurement of Y .
6 / 28
The population regression model in a picture
7 / 28
The Ordinary Least Squares Estimator (SW Section 4.2)
▶ How can we estimate β0 and β1 from data? Recall that was the least
squares estimator of µY solves,
n
X
min (Yi − m)2
m
i=1
8 / 28
Mechanics of OLS
9 / 28
Mechanics of OLS
10 / 28
OLS estimator, predicted values, and residuals
βb0 = Y − βb1 X
▶ These are estimates of the unknown population parameters β0 and β1 .
▶ The OLS predicted (fitted) values Y
bi and residuals u
bi are
Y
bi = βb0 + βb1 Xi
bi = Yi − Y
u bi
11 / 28
Predicted values & residuals
▶ One of the districts in the data set is Antelope, CA, for which
STR = 19.33 and TestScore = 657.8
12 / 28
OLS regression: R output
13 / 28
Measures of fit Section 4.3
14 / 28
Regression R 2
15 / 28
The Standard Error of the Regression (SER)
▶ The SER:
▶ has the units of ui , which are the units of Yi
▶ measures the average “size” of the OLS residual (the average “mistake”
made by the OLS regression line)
▶ The root mean squared error (RMSE) is closely related to the SER:
v
u n
u1 X
RMSE := t bi2
u
n
i=1
1
Here, n − 2 is the degrees of freedom – need to subtract 2 because there are two parameters
to estimate. For details, see section 18.4.
16 / 28
Example of the R 2 and the SER
17 / 28
Least Squares Assumptions (SW Section 4.4)
18 / 28
Least Squares Assumptions (SW Section 4.4)
Yi = β0 + β1 Xi + ui , i = 1, . . . , n
19 / 28
Least squares assumption #1: E(u|X = x) = 0.
20 / 28
Least squares assumption #1: E(u|X = x) = 0 (continued)
21 / 28
Least squares assumption #2: (Xi , Yi ), i = 1, · · · , n are i.i.d.
22 / 28
Least squares assumption #3: Large outliers are rare
Technical statement: E(X 4 ) < ∞ and E(Y 4 ) < ∞
23 / 28
OLS can be sensitive to an outlier
24 / 28
The Sampling Distribution of the OLS Estimator (SW Section 4.5)
25 / 28
Sampling Distribution of βb1
▶ We can show that βb1 is unbiased, i.e., E[βb1 ] = β1 . Similarly for βb0 .
▶ We do not derive V (βb1 ), as it requires some tedious algebra. Moreover,
we do not need to memorize the formula of it. Here, we just emphasize
two aspects of V (βb1 ).
▶ First, V (βb1 ) is inversely proportional to n, just like V (Y n ). Combining
p
E[βb1 ] = β1 , it is then suggested that βb1 −→ β1 , i.e., βb1 is consistent.
That is, as sample size grows, β1 gets closer to β1 .
b
▶ Second, V (βb1 ) is inversely proportional to the variance of X ; see the
graphs below.
26 / 28
Sampling Distribution of βb1
27 / 28
Sampling Distribution of βb1
βb1 − β1 approx
∼ N (0, 1)
SE(βb1 )
▶ Using this approximate distribution, we can conduct statistical inference
on βb1 , i.e., hypothesis testing, confidence interval ⇒ Ch5.
28 / 28