Title: | Categorical Instrumental Variables |
---|---|
Description: | Implementation of the categorical instrumental variable (CIV) estimator proposed by Wiemann (2023) <arXiv:2311.17021>. CIV allows for optimal instrumental variable estimation in settings with relatively few observations per category. To obtain valid inference in these challenging settings, CIV leverages a regularization assumption that implies existence of a latent categorical variable with fixed finite support achieving the same first stage fit as the observed instrument. |
Authors: | Thomas Wiemann [aut, cre] |
Maintainer: | Thomas Wiemann <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.0.9000 |
Built: | 2024-11-18 03:09:24 UTC |
Source: | https://github.com/thomaswiemann/civ |
Implementation of the categorical instrumental variable estimator.
civ(y, D, Z, X = NULL, K = 2, regularize_EDZ = FALSE)
civ(y, D, Z, X = NULL, K = 2, regularize_EDZ = FALSE)
y |
The outcome variable, a numerical vector. |
D |
A matrix of endogenous variables. |
Z |
A matrix of instruments, where the first column corresponds to the categorical instrument. |
X |
An optional matrix of control variables. |
K |
The number of support points of the estimated instrument
|
regularize_EDZ |
A boolean indicating whether |
civ
returns an object of S3 class civ
. An object of
class civ
is a list containing the following components:
coef
A vector of second-stage coefficient estimates.
iv_fit
Object of class ivreg
from the IV
regression of y
on D
and X
using the
the estimated as an instrument for
D
.
See also AER::ivreg()
for details.
kcmeans_fit
Object of class kcmeans
from the
K-Conditional-Means regression of D
on Z
and
X
. See also kcmeans::kcmeans()
for details.
Pass-through of selected user-provided arguments. See above.
Fox J, Kleiber C, Zeileis A (2023). "ivreg: Instrumental-Variables Regression by '2SLS', '2SM', or '2SMM', with Diagnostics". R package.
Wiemann T (2023). "Optimal Categorical Instruments." https://arxiv.org/abs/2311.17021
# Simulate data from a simple IV model with 800 observations nobs = 800 # sample size Z <- sample(1:20, nobs, replace = TRUE) # observed instrument Z0 <- Z %% 2 # underlying latent instrument U_V <- matrix(rnorm(2 * nobs, 0, 1), nobs, 2) %*% chol(matrix(c(1, 0.6, 0.6, 1), 2, 2)) # first and second stage errors D <- Z0 + U_V[, 2] # endogenous variable y <- D + U_V[, 1] # outcome variable # Estimate categorical instrument variable estimator with K = 2 civ_fit <- civ(y, D, Z, K = 3) summary(civ_fit)
# Simulate data from a simple IV model with 800 observations nobs = 800 # sample size Z <- sample(1:20, nobs, replace = TRUE) # observed instrument Z0 <- Z %% 2 # underlying latent instrument U_V <- matrix(rnorm(2 * nobs, 0, 1), nobs, 2) %*% chol(matrix(c(1, 0.6, 0.6, 1), 2, 2)) # first and second stage errors D <- Z0 + U_V[, 2] # endogenous variable y <- D + U_V[, 1] # outcome variable # Estimate categorical instrument variable estimator with K = 2 civ_fit <- civ(y, D, Z, K = 3) summary(civ_fit)
Inference methods for the categorical instrumental variable
estimators. Simple wrapper for AER::summary.ivreg()
.
## S3 method for class 'civ' summary(object, ...)
## S3 method for class 'civ' summary(object, ...)
object |
An object of class |
... |
Additional arguments passed to |
An object of class summary.ivreg
with inference results.
Fox J, Kleiber C, Zeileis A (2023). "ivreg: Instrumental-Variables Regression by '2SLS', '2SM', or '2SMM', with Diagnostics". R package.
Wiemann T (2023). "Optimal Categorical Instruments." https://arxiv.org/abs/2311.17021
# Simulate data from a simple IV model with 800 observations nobs = 800 # sample size Z <- sample(1:20, nobs, replace = TRUE) # observed instrument Z0 <- Z %% 2 # underlying latent instrument U_V <- matrix(rnorm(2 * nobs, 0, 1), nobs, 2) %*% chol(matrix(c(1, 0.6, 0.6, 1), 2, 2)) # first and second stage errors D <- Z0 + U_V[, 2] # endogenous variable y <- D + U_V[, 1] # outcome variable # Estimate categorical instrument variable estimator with K = 2 civ_fit <- civ(y, D, Z, K = 3) summary(civ_fit)
# Simulate data from a simple IV model with 800 observations nobs = 800 # sample size Z <- sample(1:20, nobs, replace = TRUE) # observed instrument Z0 <- Z %% 2 # underlying latent instrument U_V <- matrix(rnorm(2 * nobs, 0, 1), nobs, 2) %*% chol(matrix(c(1, 0.6, 0.6, 1), 2, 2)) # first and second stage errors D <- Z0 + U_V[, 2] # endogenous variable y <- D + U_V[, 1] # outcome variable # Estimate categorical instrument variable estimator with K = 2 civ_fit <- civ(y, D, Z, K = 3) summary(civ_fit)