I want to do the two-stage least squares estimation with time series. I know I can do it manually, but the standard errors then are not right.
I accidentally saw in the description of the dynlm
package that it includes 2SLS estimation. However, I don't seem to understand how to do it. All that we are given in the instructions is:
To specify a set of instruments, formulas of type
y ~ x1 + x2 | z1 + z2
y ~ x1 + x2 | z1 + z2
can be used where z1 and z2 represent the instruments.
How do I specify which variable ( x1
or x2
) is endogenous (and would be dependent variable in the first stage)?
On the right of |
you want to specify all the instruments - including the exogenous variable already in the equation. Whatever is not on the right will be instrumented - assumed to be endogenous. So, if x1
is exogenous, x2
is endogenous, and you have one extra instrument z1
, then you want
y ~ x1 + x2 | z1 + x1
To see that this is right, try including just z1
on the right: then one coefficient will be not identified.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.