-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathIV_Schaetzung.R
More file actions
33 lines (25 loc) · 1.06 KB
/
Copy pathIV_Schaetzung.R
File metadata and controls
33 lines (25 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
################################
# Instrumentvariablenschätzung #
################################
# Zusatzprogramm FOREIGN installieren und aktivieren
install.packages("foreign", dependencies=TRUE)
library(foreign)
# Zusatzprogramm AER installieren und aktivieren
install.packages("AER", dependencies=TRUE)
library(AER)
# Zusatzprogramm STARGAZER installieren und aktivieren
install.packages("stargazer", dependencies=TRUE)
library(stargazer)
# Datensatz von Server laden
mroz <- read.dta("http://fmwww.bc.edu/ec-p/data/wooldridge/mroz.dta")
head(mroz)
# Subset anlegen
oursample <- subset(mroz, !is.na(wage))
# Einfaches Regressionsmodell
lm(data = oursample, educ ~ fatheduc)
# Modelle aufsetzen
stage1 <- lm(educ ~ exper + I(exper^2) + motheduc + fatheduc, data = oursample)
man.2SLS <- lm(log(wage) ~ fitted(stage1) + exper + I(exper^2), data = oursample)
aut.2SLS <- ivreg(log(wage) ~ educ + exper + I(exper^1) | motheduc + fatheduc + exper + I(exper^2), data = oursample)
# Modelle vergleichen
stargazer(stage1, man.2SLS, aut.2SLS, type="text", keep.stat=c("n", "rsq"))