MDEI | R Documentation |
Implements the Method of Direct Estimation and Inference
MDEI(
y,
treat,
X,
splits = 10,
alpha = 0.9,
samplesplit = TRUE,
conformal = TRUE,
nthreads.ranger = NULL,
verbose = TRUE
)
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 |
The estimated marginal effect.
Upper and lower values of conformal confidence band.
Conformal critical values.
Mean of outcome given only covariates.
The list of all nonparametric bases and the proportion of sample splits that they were selected.
Internal objects used for development and diagnostics.
Ratkovic, Marc and Dustin Tingley. 2023. "Estimation and Inference on Nonlinear and Heterogeneous Effects." The Journal of Politics.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.