View source: R/ivmodelFormula.r
ivmodelFormula | R Documentation |
ivmodelFormula
fits an instrumental variables (IV) model with one endogenous variable and a continuous outcome. It carries out several IV regressions, diagnostics, and tests associated this IV model. It is robust to most data formats, including factor and character data, and can handle very large IV models efficiently.
ivmodelFormula(formula, data, subset,
beta0=0,alpha=0.05,k=c(0,1),
manyweakSE = FALSE,
heteroSE = FALSE, clusterID = NULL,
deltarange=NULL, na.action = na.omit)
formula |
a formula describing the model to be fitted. For example, the formula
and
The outcome is |
data |
an optional data frame containing the variables in the model.
By default the variables are taken from the environment which |
subset |
an index vector indicating which rows should be used. |
beta0 |
Null value |
alpha |
The significance level for hypothesis testing. Default is 0.05. |
k |
A numeric vector of k values for k-class estimation. Default is 0 (OLS) and 1 (TSLS). |
manyweakSE |
Should many weak instrument (and heteroscedastic-robust) asymptotics in Hansen, Hausman and Newey (2008) be used to compute standard errors? (Not supported for k ==0) |
heteroSE |
Should heteroscedastic-robust standard errors be used? Default is FALSE. |
clusterID |
If cluster-robust standard errors are desired, provide a vector of length that's identical to the sample size. For example, if n = 6 and clusterID = c(1,1,1,2,2,2), there would be two clusters where the first cluster is formed by the first three observations and the second cluster is formed by the last three observations. clusterID can be numeric, character, or factor. |
deltarange |
Range of |
na.action |
NA handling. There are |
Let Y
, D
, X
, and Z
represent the outcome, endogenous variable, p dimensional exogenous covariates, and L dimensional instruments, respectively. ivmodel
assumes the following IV model
Y = X \alpha + D \beta + \epsilon, E(\epsilon | X, Z) = 0
and produces statistics for \beta
. In particular, ivmodel
computes the OLS, TSLS, k-class, limited information maximum likelihood (LIML), and Fuller-k (Fuller 1977) estimates of \beta
using KClass
, LIML
, and codeFuller. Also, ivmodel
computes confidence intervals and hypothesis tests of the type H_0: \beta = \beta_0
versus H_0: \beta \neq \beta_0
for the said estimators as well as two weak-IV confidence intervals, Anderson and Rubin (Anderson and Rubin 1949) confidence interval (Anderson and Rubin 1949) and the conditional likelihood ratio confidence interval (Moreira 2003). Finally, the code also conducts a sensitivity analysis if Z
is one-dimensional (i.e. there is only one instrument) using the method in Jiang et al. (2015).
Some procedures (e.g. conditional likelihood ratio test, sensitivity analysis with Anderson-Rubin) assume an additional linear model
D = Z \gamma + X \kappa + \xi, E(\xi | X, Z) = 0
ivmodel
returns an object of class "ivmodel".
An object class "ivmodel" is a list containing the following components
n |
Sample size. |
L |
Number of instruments. |
p |
Number of exogenous covariates (including intercept). |
Y |
Outcome, cleaned for use in future methods. |
D |
Treatment, cleaned for use in future methods. |
Z |
Instrument(s), cleaned for use in future methods. |
X |
Exogenous covariates (if provided), cleaned for use in future methods. |
Yadj |
Adjusted outcome, projecting out X. |
Dadj |
Adjusted treatment, projecting out X. |
Zadj |
Adjusted instrument(s), projecting out X. |
ZadjQR |
QR decomposition for adjusted instrument(s). |
ZXQR |
QR decomposition for concatenated matrix of Z and X. |
alpha |
Significance level for the hypothesis tests. |
beta0 |
Null value of the hypothesis tests. |
kClass |
A list from |
LIML |
A list from |
Fuller |
A list from |
AR |
A list from |
CLR |
A list from |
In addition, if there is only one instrument, ivreg
will generate an "ARsens" list within "ivmodel" object.
Yang Jiang, Hyunseung Kang, and Dylan Small
Anderson, T. W. and Rubin, H. (1949). Estimation of the parameters of a single equation in a complete system of stochastic equations. Annals of Mathematical Statistics 20, 46-63.
Freeman G., Cowling B. J., Schooling C. M. (2013). Power and Sample Size Calculations for Mendelian Randomization Studies Using One Genetic Instrument. International Journal of Epidemiology 42(4), 1157-1163.
Fuller, W. (1977). Some properties of a modification of the limited information estimator. Econometrica, 45, 939-953.
Hansen, C., Hausman, J., and Newey, W. (2008) Estimation with many instrumental variables. Journal of Business and Economic Statistics 26(4), 398-422.
Moreira, M. J. (2003). A conditional likelihood ratio test for structural models. Econometrica 71, 1027-1048.
Sargan, J. D. (1958). The estimation of economic relationships using instrumental variables. Econometrica , 393-415.
Wang, X., Jiang, Y., Small, D. and Zhang, N. (2017), Sensitivity analysis and power for instrumental variable studies. Biometrics 74(4), 1150-1160.
See also KClass
, LIML
, Fuller
, AR.test
, and CLR
for individual methods associated with ivmodel
. For extracting the estimated effect of the exogenous covariates on the outcome, see coefOther
. For sensitivity analysis with the AR test,
see ARsens.test
. ivmodel
has vcov.ivmodel
,model.matrix.ivmodel
,summary.ivmodel
, confint.ivmodel
, fitted.ivmodel
,
residuals.ivmodel
and coef.ivmodel
methods associated with it.
data(card.data)
# One instrument #
Y=card.data[,"lwage"]
D=card.data[,"educ"]
Z=card.data[,"nearc4"]
Xname=c("exper", "expersq", "black", "south", "smsa", "reg661",
"reg662", "reg663", "reg664", "reg665", "reg666", "reg667",
"reg668", "smsa66")
X=card.data[,Xname]
card.model1IV = ivmodelFormula(lwage ~ educ + exper + expersq + black +
south + smsa + reg661 +
reg662 + reg663 + reg664 +
reg665 + reg666 + reg667 +
reg668 + smsa66 | nearc4 +
exper + expersq + black +
south + smsa + reg661 +
reg662 + reg663 + reg664 +
reg665 + reg666 + reg667 +
reg668 + smsa66,data=card.data)
card.model1IV
# Multiple instruments
Z = card.data[,c("nearc4","nearc2")]
card.model2IV = ivmodelFormula(lwage ~ educ + exper + expersq + black +
south + smsa + reg661 +
reg662 + reg663 + reg664 +
reg665 + reg666 + reg667 +
reg668 + smsa66 | nearc4 + nearc2 +
exper + expersq + black +
south + smsa + reg661 +
reg662 + reg663 + reg664 +
reg665 + reg666 + reg667 +
reg668 + smsa66,data=card.data)
card.model2IV
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.