Title: | Implementing the Method of Direct Estimation and Inference |
---|---|
Description: | Causal and statistical inference on an arbitrary treatment effect curve requires care in both estimation and inference. This package, implements the Method of Direct Estimation and Inference as introduced in "Estimation and Inference on Nonlinear and Heterogeneous Effects" by Ratkovic and Tingley (2023) <doi:10.1086/723811>. The method takes an outcome, variable of theoretical interest (treatment), and set of variables and then returns a partial derivative (marginal effect) of the treatment variable at each point along with uncertainty intervals. The approach offers two advances. First, a split-sample approach is used as a guard against over-fitting. Second, the method uses a data-driven interval derived from conformal inference, rather than relying on a normality assumption on the error terms. |
Authors: | Marc Ratkovic [aut, cre], Dustin Tingley [ctb], Nithin Kavi [aut] |
Maintainer: | Marc Ratkovic <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2024-11-17 06:42:31 UTC |
Source: | CRAN |
MDEI estimates effects.
Maintainer: Marc Ratkovic [email protected]
Authors:
Nithin Kavi [email protected]
Other contributors:
Dustin Tingley [email protected] [contributor]
Coverage Plot for MDEI Object
coverPlot( object, xvar = "treat", sigval = 0, target = "tau", colors = c(gray(0.7), gray(0)), cex.point = 0.5, xlabel = "", ylabel = "", ... )
coverPlot( object, xvar = "treat", sigval = 0, target = "tau", colors = c(gray(0.7), gray(0)), cex.point = 0.5, xlabel = "", ylabel = "", ... )
object |
An object of class MDEI. |
xvar |
The variable to plot along the x-axis. May be 'treat' for the treatment
variable, the name of a column in the covariate matrix in the |
sigval |
The value to see if it is covered by the conformal interval. Either a single value or a vector. Default is |
target |
Either tau' or 'theta'. The first, 'tau', is the marginal effect at each point, while the second 'theta', is the portion of the conditional mean of the outcome that is a function of the treatment and the outcome. |
colors |
A vector with two elements. The first is the color of the confidence interval at points
where the conformal interval does not contain |
cex.point |
The size of the points in the figure. Default is |
xlabel |
Label for x-axis of figure. Default is |
ylabel |
Label for y-axis of figure. Default is |
... |
Additional arguments to be passed to |
No return value.
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 )
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)
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)
Summary of an object of class MDEI.
## S3 method for class 'MDEI' summary(object, features = 10, ...)
## S3 method for class 'MDEI' summary(object, features = 10, ...)
object |
An object of class MDEI. |
features |
Number of spline bases to include. |
... |
Additional arguments to be passed to |
A table with three columns: the names of selected spline interactions, the average coefficient, and
proportion of time it was included in the model. Averages over taken over subsamples in the
split sample strategy.Note that the coefficients are interactions between
spline interactions that can be accessed through obj$internal$Xmat.spline
.