14 Introduction to Instrumental Variables
When OLS fails due to endogeneity, IV estimation helps bring back causal effects.
14.0.1 Idea:
Use a third variable (instrument Z) that:
- is correlated with X (relevance condition)
- does NOT affect Y except through X (exclusion restriction)
- Is uncorrelated with the error term.
The instrument isolates variation in X that is not contaminated by omitted variables. Instead of using all variation in X, IV uses only exogenous variation.
14.0.1.1 Simulated Instrument
n<-500 #sample size
ability<-rnorm(n)
instrument<-rnorm(n)
educ_iv<-2+instrument+ability+rnorm(n)
wage<-5+3*educ_iv+2*ability+rnorm(n)
ivd<-data.frame(wage,educ_iv, instrument)We generate ability, our unobserved factor affecting both education and wage (this is what creats endogeneity). We generate our instrument variable Z, must influence education but not directly wage. We build our education_iv which depends on instrument (relevance condition) and ability (source of endogeneity) plus random noise. We also simulate wage.
14.0.1.2 Running IV regression
We use the AER package which has functions for instrumental variable regression. We use ivreg to do instrumental variable regression. Inside the parenthesis: outcome ~ endogenous_var | instrument. The vertical bar separates regressors from instruments.
##
## Call:
## ivreg(formula = wage ~ educ_iv | instrument, data = ivd)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.74777 -1.52934 0.04787 1.33048 6.78178
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.06622 0.21581 23.48 <0.0000000000000002
## educ_iv 3.02180 0.09399 32.15 <0.0000000000000002
##
## (Intercept) ***
## educ_iv ***
## ---
## Signif. codes:
## 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.102 on 498 degrees of freedom
## Multiple R-Squared: 0.8951, Adjusted R-squared: 0.8949
## Wald test: 1034 on 1 and 498 DF, p-value: < 0.00000000000000022
A one-unit increase in education is associated with a 3.02 increase in wage, and is statistically significant.
The p-value of 0.895 shows that there is strong evidence of a causal effect from the model.
Despite \(R^2\) being a measure of goodness-of-fit, in IV, where it does not minimize residual variance, some \(R^2\) becomes negative. As a whole, \(R^2\) is not a useful tool for goodness of fit in IV.
14.0.1.3 Diagnostics
##
## Call:
## ivreg(formula = wage ~ educ_iv | instrument, data = ivd)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.74777 -1.52934 0.04787 1.33048 6.78178
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.06622 0.21581 23.48 <0.0000000000000002
## educ_iv 3.02180 0.09399 32.15 <0.0000000000000002
##
## (Intercept) ***
## educ_iv ***
##
## Diagnostic tests:
## df1 df2 statistic p-value
## Weak instruments 1 498 252.87 <0.0000000000000002 ***
## Wu-Hausman 1 497 88.01 <0.0000000000000002 ***
## Sargan 0 NA NA NA
## ---
## Signif. codes:
## 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.102 on 498 degrees of freedom
## Multiple R-Squared: 0.8951, Adjusted R-squared: 0.8949
## Wald test: 1034 on 1 and 498 DF, p-value: < 0.00000000000000022
Weak instruments tests if instrument is weak or instrument is strong. The instrument in this case, does not strongly predict education. The IV here is weak, leading to biased estimates.
Wu-Hausman tests for endogeneity. The alternative is that endogeneity is present. There is endogeneity here (education is endogenous in the model).
Sargan tests for multiple instruments (to be discussed later)