Evaluating Heterogeneous Treatment Effects

Provides various statistical methods for evaluating heterogeneous treatment effects (HTE) in randomized experiments. The package includes tools to estimate uniform confidence bands for estimation of the group average treatment effect sorted by generic machine learning algorithms (GATES). It also provides the tools to identify a subgroup of individuals who are likely to benefit from a treatment the most "exceptional responders" or those who are harmed by it. Detailed reference in Imai and Li (2023) .


evalHTE

CRAN status Downloads

Overview

evalHTE provides statistical methods for evaluating heterogeneous treatment effects (HTE) in randomized experiments. The package implements the methodology developed in Imai and Li (2025) for:

  • Estimating Grouped Average Treatment Effects (GATEs) with uniform confidence bands
  • Identifying exceptional responders — individuals who benefit the most (or are harmed) by a treatment
  • Conducting hypothesis tests for treatment effect heterogeneity and consistency
  • Supporting both sample splitting and cross-validation approaches

Installation

From CRAN

install.packages("evalHTE")

Development Version from GitHub

# install.packages("devtools")
devtools::install_github("MichaelLLi/evalHTE")

Key Features

Feature Description
GATE Estimation Estimate grouped average treatment effects sorted by ML-predicted treatment effects
Uniform Confidence Bands Construct valid confidence intervals that account for multiple testing
Exceptional Responders Identify subgroups with the largest treatment effects using URATE
Hypothesis Testing Test for heterogeneity and consistency of treatment effects across groups
Cross-Validation Support Proper inference under cross-fitting to avoid overfitting
Flexible ML Integration Works with various ML algorithms via caret or user-defined models

Quick Start

library(evalHTE)

# Prepare your data with outcome (y), treatment (z), and covariates
data <- data.frame(
  y = outcome_variable,
  z = treatment_indicator,
  x1 = covariate_1,
  x2 = covariate_2
)

# Step 1: Estimate heterogeneous treatment effects
fit <- estimate_hte(
  treatment = "z",
  form = y ~ z * (x1 + x2),
  data = data,
  algorithms = c("causal_forest"),
  n_folds = 5,
  ngates = 5
)

# Step 2: Evaluate the estimated HTE
est <- evaluate_hte(fit)

# Step 3: View summary results
summary(est)

# Step 4: Conduct hypothesis tests
test_results <- test_itr(est)
summary(test_results)

# Step 5: Visualize results
plot(est)                # Plot GATE estimates
plot_CI(est, alpha = 0.05)  # Plot uniform confidence intervals

Main Functions

Estimation

Function Description
estimate_hte() Estimate heterogeneous treatment effects using ML algorithms
evaluate_hte() Evaluate and summarize HTE estimates
test_itr() Conduct hypothesis tests for heterogeneity and consistency

GATE Functions

Function Description
GATE() Estimate Grouped Average Treatment Effects (sample splitting)
GATEcv() Estimate GATEs under cross-validation

Hypothesis Tests

Function Description
het.test() Test for heterogeneous treatment effects across groups
hetcv.test() Heterogeneity test under cross-validation
consist.test() Test for consistency of treatment effect ranking
consistcv.test() Consistency test under cross-validation

Exceptional Responders

Function Description
URATE() Estimate the Uplift RATE curve for identifying exceptional responders

Visualization

Function Description
plot.hte() Plot GATE estimates with confidence intervals
plot_CI() Plot uniform and pointwise confidence bands

Example with Simulated Data

library(evalHTE)
library(grf)

# Simulate data
set.seed(123)
n <- 1000
X <- matrix(rnorm(n * 5), n, 5)
colnames(X) <- paste0("x", 1:5)
tau <- X[, 1] + 0.5 * X[, 2]  # True treatment effect heterogeneity
W <- rbinom(n, 1, 0.5)        # Random treatment assignment
Y <- tau * W + rnorm(n)       # Observed outcome

# Create data frame
df <- data.frame(X, y = Y, z = W)

# Estimate HTE using causal forest
fit <- estimate_hte(
  treatment = "z",
  form = y ~ z * (x1 + x2 + x3 + x4 + x5),
  data = df,
  algorithms = c("causal_forest"),
  n_folds = 5,
  ngates = 5
)

# Evaluate results
est <- evaluate_hte(fit)
summary(est)

# Visualize GATE estimates
plot(est)

Supported Algorithms

The package supports various machine learning algorithms for estimating treatment effects:

  • Causal Forest (causal_forest) via the grf package
  • S-learner and T-learner meta-learners
  • Any algorithm supported by caret
  • User-defined custom models

Citation

If you use this package in your research, please cite:

@article{imai2025statistical,
  title={Statistical Inference for Heterogeneous Treatment Effects Discovered by Generic Machine Learning in Randomized Experiments},
  author={Imai, Kosuke and Li, Michael Lingzhi},
  journal={Journal of Business \& Economic Statistics},
  volume={43},
  number={1},
  pages={256--268},
  year={2025},
  doi={10.1080/07350015.2024.2358909}
}

Or in R:

citation("evalHTE")

Authors

Contributor:

  • Jialu Li - Harvard University

Related Packages

  • evalITR - Evaluation of Individualized Treatment Rules
  • grf - Generalized Random Forests
  • caret - Classification and Regression Training

License

MIT License

References

Imai, K. and Li, M. L. (2025). "Statistical Inference for Heterogeneous Treatment Effects Discovered by Generic Machine Learning in Randomized Experiments." Journal of Business & Economic Statistics, Vol. 43, No. 1, pp. 256-268. https://doi.org/10.1080/07350015.2024.2358909

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("evalHTE")

0.2.0 by Michael Lingzhi Li, a month ago


Browse source code at https://github.com/cran/evalHTE


Authors: Michael Lingzhi Li [aut, cre] , Kosuke Imai [aut] , Jialu Li [ctb]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, evalITR, ggplot2, ggthemes, rlang, zoo, furrr, ggdist, scales, tidyr, stats, purrr, caret

Depends on dplyr

Suggests testthat, knitr, rmarkdown, future, grf, magrittr, tibble


See at CRAN