ivDiag | R Documentation |
Conducts various estimation and diagnostic procedure for instrumental variable designs in one shot.
ivDiag(data, Y, D, Z, controls = NULL, FE = NULL, cl = NULL, weights = NULL,
bootstrap = TRUE, run.AR = TRUE,
nboots = 1000, parallel = TRUE, cores = NULL,
seed = 94305, prec = 4, debug = FALSE)
data |
name of a dataframe. |
Y |
a string indicating the outcome variable. |
D |
a string indicating the treatment variable. |
Z |
a vector of strings indicating the instrumental variables. |
controls |
a vector of strings indicating the control variables. |
FE |
a vector of strings indicating the fixed effects variables. |
cl |
a string indicating the clustering variable. |
weights |
a string indicating the variable that stores weights. |
bootstrap |
whether to turn on bootstrap (TRUE by default). |
run.AR |
whether to run AR test (TRUE by default). |
nboots |
a numeric value indicating the number of bootstrap runs. |
parallel |
a logical flag controlling parallel computing. |
cores |
setting the number of cores. |
prec |
precision of CI in string (4 by default). |
seed |
setting seed. |
debug |
for debugging purposes. |
est_ols |
results from an OLS regression. |
est_2sls |
results from a 2SLS regression. |
AR |
results from an Anderson-Rubin test |
F_stat |
various F statistics. |
rho |
Pearson correlation coefficient between the treatment and predicted treatment from the first stage regression (all covariates are partialled out). |
tF |
results from the tF procedure based on Lee et al. (2022) |
est_rf |
results from the reduced form regression. |
est_fs |
results from the first stage regression. |
p_iv |
the number of instruments. |
N |
the number of observations. |
N_cl |
the number of clusters. |
df |
the degree of freedom left from the 2SLS regression |
nvalues |
the unique values the outcome Y, the treatment D, and each instrument in Z in the 2SLS regression. |
Apoorva Lal; Yiqing Xu
Lal, Apoorva, Mackenzie William Lockhart, Yiqing Xu, and Ziwen Zu. 2023. "How Much Should We Trust Instrumental Variable Estimates in Political Science? Practical Advice Based on 67 Replicated Studies." Available at: https://yiqingxu.org/papers/english/2021_iv/LLXZ.pdf
Lee, David S, Justin McCrary, Marcelo J Moreira, and Jack Porter. 2022. "Valid t-Ratio Inference for IV." American Economic Review 112 (10): 3260–90.
plot_coef
eff_F
AR_test
tF
data(ivDiag)
g <- ivDiag(data = rueda, Y = "e_vote_buying", D = "lm_pob_mesa",
Z = "lz_pob_mesa_f", controls = c("lpopulation", "lpotencial"),
cl = "muni_code", bootstrap = FALSE, run.AR = FALSE)
plot_coef(g)
library(testthat)
test_that("Check ivDiag output", {
expect_equal(as.numeric(g$est_2sls[1,1]), -0.9835)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.