MDEI {MDEI} | R Documentation |
MDEI function
Description
Implements the Method of Direct Estimation and Inference
Usage
MDEI(
y,
treat,
X,
splits = 10,
alpha = 0.9,
samplesplit = TRUE,
conformal = TRUE,
nthreads.ranger = NULL,
verbose = TRUE
)
Arguments
y |
The outcome variable, a vector. |
treat |
The treatment variable, a vector. |
X |
A matrix of covariates. |
splits |
Number of repeated cross-fitting steps to implement. |
alpha |
The desired level of the confidence band. |
samplesplit |
Whether to use a sample splitting approach. Default is |
conformal |
Whether to generate a conformal bands or use a critical value from the
normal approximation. Default is |
nthreads.ranger |
Number of threads used internally by the |
verbose |
An optional logical value. If |
Value
- tau.est
The estimated marginal effect.
- CIs.tau
Upper and lower values of conformal confidence band.
- critical.values
Conformal critical values.
- Ey.x
Mean of outcome given only covariates.
- coefficients
The list of all nonparametric bases and the proportion of sample splits that they were selected.
- internal
Internal objects used for development and diagnostics.
References
Ratkovic, Marc and Dustin Tingley. 2023. "Estimation and Inference on Nonlinear and Heterogeneous Effects." The Journal of Politics.
Examples
n <- 100
X <- matrix(rnorm(n*1), nrow = n)
treat <- rnorm(n)
y <- treat^2 + X[,1] + rnorm(n)
# Be sure to run with more splits than this. We recommend
# at least 10-50 initially, for exploratory analyses, with several hundred for
# publication quality. For large sample sizes, these numbers may be adjusted down.
# These are only recommendations.
# Threads are set to 1 to pass CRAN checks, but we suggest leaving it at the default
# which ranger takse as the total number available.
set.seed(1)
m1 <- MDEI(y, treat, X, splits=1, alpha=.9, nthreads.ranger = 1)
# Accuracy
cor(m1$tau.est, treat*2)
cor(m1$theta.est, treat^2)
# Coverage
mean(apply(m1$CIs.tau-2*treat,1,prod)<0)