Lecture4 Linearregression Oneregressor
Lecture4 Linearregression Oneregressor
Monique de Haan
(moniqued@econ.uio.no)
Lecture outline
• E (ui |Xi ) = 0
• unbiasedness
• consistency
Yi = β0 + β1 Xi + ui
c0 = Y − βb1 X
β
1
Pn
n−1 i=1 (Xi −X )(Yi −Y ) sxy
β
c1 = 1
Pn = sx2
,
n−1 i=1 (Xi −X )(Xi −X )
4
Robust
test_score Coef. Std. Err. t P>|t| [95% Conf. Interval]
Yi = β0 + β1 Xi + ui
Under what assumptions does the method of ordinary least squares provide
appropriate estimators of β0 and β0 ?
Under what assumptions does the method of ordinary least squares provide
an appropriate estimator of the effect of class size on test scores?
E (ui |Xi ) = 0
E (ui |Xi ) = 0
All other factors that affect the dependent variable Yi (contained in ui ) are
unrelated to Xi in the sense that, given a value of Xi , the mean of these other
factors equals zero.
All the other factors affecting test scores should be unrelated to class size in
the sense that, given a value of class size, the mean of these other factors
equals zero.
7
Expectation rules
= β0 + β1 Xi
8
E (Yi |Xi ) = β0 + β1
9
Suppose that
• districts with poor inhabitants have large classes and bad teachers.
• These districts have little money and can hire only few and not very
good teachers
• Outliers are observations that have values far outside the usual range of
the data
Yi = β0 + β1 Xi + ui
If the 3 least squares assumptions hold the OLS estimators βb0 and βb1
Yi = β0 + β1 Xi + ui Y = β0 + β1 Xi + u
Pn
(Xi −X )(Yi −Y )
h i
i=1
E βb1 =E Pn
i=1 (Xi −X )(Xi −X )
substitute for Yi , Y
Pn
i=1 (Xi −X )(β0 +β1 Xi +ui −(β0 +β1 X +u))
=E Pn
i=1 (Xi −X )(Xi −X )
.
β1 ni=1 (Xi −X )(Xi −X )
Pn
(Xi −X )(ui −u)
h i P
i=1
E βb1 =E Pn +E Pn
i=1 ( i
X −X )(Xi −X ) i=1 ( i
X −X )(Xi −X )
h i
E βb1 = β1 if E [ui |Xi ] = 0
16
Algebra trick
Pn Pn Pn Pn Pn
i=1 Xi − X (ui − u) = i=1 Xi ui − i=1 Xi u − i=1 X ui + i=1 Xu
Pn 1
Pn Pn
= i=1 Xi ui − n · n i=1 Xi u − i=1 X ui + nX u
Pn
Xi ui − nX u + ni=1 X ui +nX u
P
= i=1
= ni=1 Xi ui − ni=1 X ui
P P
P
= ni=1 Xi − X ui
17
Consistency
p
b1 −→ β1
Consistency:β or plim βb1 = β1
Pn
i=1 (Xi −X )(Yi −Y )
Plim βb1 = plim Pn
i=1 (Xi −X )(Xi −X )
1 Pn
Plim n−1 i=1 (Xi −X )(Yi −Y ) sXY
= 1 Pn = 2
i=1 ( i
Plim n−1 X −X )(Xi −X ) sX
substitute for Yi
Cov (Xi ,β0 +β1 Xi +ui )
= Var (Xi )
Consistency
= β1 Var (Xi )
Var (X )
+ Cov (Xi ,ui )
Var (Xi )
i
algebra trick
E[(Xi −µx )ui ]
= β1 + Var (Xi )
Unbiasedness vs Consistency
• Xi ∼ N(0, 1)
• ui ∼ N(0, 1)
1 . sum y x
A simulation example
Y
0
1 . regress y x
2 .
3 . simulate _b, reps(999) nodots : ols
command: ols
4 . sum
0
1.6 1.8 2 2.2 2.4
OLS estimates of B1
24
A simulation example
Tuesday February n=1000
17 13:03:15 2015 Page 1
2 .
3 . simulate _b, reps(999) nodots : ols
command: ols
4 . sum
10
0
1.6 1.8 2 2.2 2.4
OLS estimates of B1
26
A simulation example
Friday January n=10000
20 12:01:22 2017 Page 1
2 .
3 . simulate _b, reps(999) nodots: ols
command: ols
4 . sum
40
30
20
10
0
1.6 1.8 2 2.2 2.4
OLS estimates of B1
28
20
.
10
0
1.6 1.7 1.8 1.9 2 2.1 2.2 2.3 2.4
OLS estimates of B1
29
σ2
Y ∼ N µY , Y
n
• Examining the formulas of the OLS estimators shows that these are
functions of sample averages:
βb0 = Y − βb1 X
1 Pn
n i=1 (Xi −X )(Yi −Y )
βb1 = 1 Pn
n i=1 (Xi −X )(Xi −X )
• It turns out that the Central Limit theorem also applies to these functions
of sample averages.
31
• The OLS estimators are unbiased which implies that (for any sample
size n)
E βb0 = β0 and E βb1 = β1
• The Central Limit theorem implies that βb0 and βb1 are approximately
jointly normally distributed in large samples:
βb0 ∼ N β0 , σβ2b
0
βb1 ∼ N β1 , σβ2b
1
32
In large samples
βb0 ∼ N β0 , σβ2b
0
βb1 ∼ N β1 , σβ2b
1
Expression for σβ2b shows that the larger the variation in the regressor Xi the
1
• Traffic fatalities are the leading cause of death for Americans between
the ages of 5 and 32.
• If many people wear seat belts the chance that people die in a car crash
is likely smaller.
• People who wear seat belts might however be more careful drivers.
• Regions with many seat belt users might have fewer traffic fatalities not
because of the seat belt usage but because the drivers are more careful.
35
• In the term paper you are going to investigate the following research
question.
• The data sets can be downloaded from the course website site.
• In analyzing this data you may consider the use of panel data methods
on top of a pure cross-section analysis.
36
• Introduction
• Empirical approach
• Data
• Results
• Conclusion
• References
• Appendix with Stata code & output
The term paper should be at most 10 pages including tables and figures (but
excluding the stata code and output).
The quality (and not the quantity) of the content of the term paper will
determine your grade.
37
• Register this group before 29 January 2017 00:00, by using link in email
you will receive today.
• If you are unable to form a group, please let me know before 29 January
2017.
• you will be randomly assigned to another student.
Important dates: