script.R
1
2
3
4
5
6
7
8
9
10
# complete the function `TSLS()`
TSLS
<-
function
(
Y
,
X
,
W
=
NULL
,
Z
,
data
)
{
fs_model
<-
lm
(
as.formula
(
paste
(
...,
collapse
=
"+"
)))
,
data
=
data
)
X_fitted
<-
...
ss_model
<-
lm
(
as.formula
(
paste
(
...,
paste
(
...,
collapse
=
"+"
)))
,
data
=
data
)
return
(
coefficients
(
...
))}
# use `TSLS()` to reproduce the estimates from
Exercise 3
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
R Console
1
>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX