I use Stata. I am trying to replicate the ivreg output of a regression performing manually the first stage, predicting the instrument after the first stage and running the second stage regression with the instrument in place of the endogenous regressor in the structural model.
Naturally, the standard errors of my second stage regression do not take into account the fact that I am using an estimated regressor: they are different from those in the output of the ivreg command.
My question is: How could I obtain reliable inference without using the ivreg command? IS there an option I should add to the second stage regression to have reliable standard errors? If not, how could I obtain reliable standard errors starting from the second stage manual regression?
Econometrics – Standard Errors of Two Stage Least Squares in Stata
econometricsinstrumental-variablesstandard errorstata
Related Question
- Solved – Instrumental variables equivalent representation
- Solved – Stata: Interaction effects between one endogenous regressor and two exogenous regressors
- Solved – Linear first stage, non-linear second stage 2SLS regression
- Solved – Control Function for IV Poisson Regression
- Econometrics – How to Manually Calculate Standard Errors for Instrumental Variables
Best Answer
The relevant formula is $$\mathbb{Var}(\beta_{IV})=\sigma^2 \cdot (X'P_{Z}X)^{-1},$$ where $$\sigma^2 = (y-X\beta_{IV})'(y-X\beta_{IV})/(n-k_{SS}),$$
and $$P_Z = Z \, (Z'Z)^{-1} Z',$$ and $k_{SS}$ is the number of regressors in the second stage. Some people will just use $n$ or $n-k_{FS}$ since the choice does not matter asymptotically.
Kit Baum has code in this thread on Old Statalist. I've tweaked it slightly to use
ivregress
rather thanivreg2
: