The sreg project

Stratified
Randomized
Experiments

sreg implements methods from modern econometric theory for estimation and inference on average treatment effects in stratified randomized experiments. It automatically applies point and variance estimators appropriate to the specified experimental design, enabling asymptotically valid inference. It supports individual- and cluster-level treatment assignment across large strata, matched pairs, general k-tuples, and mixed designs.

ImplementationsR/Stata/Python
Conceptual illustration of stratified randomization: blue and ivory units grouped beneath two distribution curves

Purpose and scope

Inference for stratified experiments

sreg is intended for researchers analyzing stratified experimental data in development economics, experimental economics, and other fields using randomized experiments. It provides a common toolkit for estimating average treatment effects and conducting inference under a broad range of stratification designs.

A fully saturated regression can recover treatment effects by aggregating stratum-specific contrasts, but its conventional heteroskedasticity-robust standard errors are not generally valid under stratified randomization. Including strata and treatment–stratum interactions does not, by itself, resolve the variance-estimation problem. See Bugni, Canay, and Shaikh (2019).

sreg implements multiple estimators introduced in the recent econometric theory literature. Given the assignment indicators, strata, and design options, it automatically applies the corresponding point and variance estimators for asymptotically valid inference, avoiding manual implementation of design-specific weights and variance corrections. It supports matched pairs, general k-tuples, large strata of potentially unequal sizes, mixed designs, multiple treatments, and cluster-level assignment, with optional optimal linear adjustment using baseline covariates. The procedures draw on recent econometric research.

Software

R, Stata, and Python implementations

Estimation and inference for stratified randomized experiments, with interfaces and reporting tools specific to each language.

RCRAN + GitHub

sreg for R

Estimation and inference in R, with S3 methods for reporting results and plotting confidence intervals.

StNative Stata / Mata

sreg for Stata

Estimation and inference in native Stata/Mata, with stored coefficient and covariance matrices and support for postestimation commands.

PyPython implementation

sreg for Python

Estimation and inference in Python, with array and DataFrame inputs and Matplotlib plots.

Estimation example

Estimation and
inference

The estimator takes observed outcomes, treatment assignments, and stratum indicators as inputs. Supplying baseline covariates selects linear covariate adjustment.

The example uses individual-level assignment and large strata. Each active treatment is compared with the control group, coded 0. The output reports ATE estimates, standard errors, and asymptotic confidence intervals.

Estimation walkthrough →
Large-strata specification
library(sreg)

fit <- sreg(
  Y = dat$Y,
  S = dat$S,
  D = dat$D,
  X = dat[c("x_1", "x_2")]
)

print(fit)
Treatment effects · Standard errors · Confidence intervals

Scope

Supported experimental designs

The appropriate estimator and variance formula depend on the stratification structure and the unit of treatment assignment.

Arguments by implementation
sregAssignment unit
Adjustment and additional design inputs

X = NULL: unadjusted; supply X for linear adjustment. Ng supplies represented cluster sizes. k identifies or validates the small-stratum size.

The assignment unit and selected strata procedure determine the estimator. With the small-strata option enabled, a common stratum size selects the small-strata procedure; varying sizes identify a mixed design, subject to the package’s classification requirements. For cluster assignment, stratum sizes and k count clusters.

Cluster assignment can be combined with large, small, or mixed strata. Multiple active treatments and covariate adjustment are supported across these designs.

Methodology

Estimators and asymptotic inference

The package implements estimators and variance formulas from the literature on covariate-adaptive randomization, matched-group designs, and cluster-randomized experiments. The methodological references state the assumptions required for consistency, asymptotic normality, and the efficiency properties of covariate adjustment.

Project team

Authors

For package questions or bug reports, please open an issue in the relevant GitHub repository: R, Stata, or Python.

Companion paper

The sreg paper

A companion paper is in preparation. It presents the estimation and inference procedures implemented in sreg, the supported experimental designs, and guidance for empirical applications.

The manuscript and its arXiv record will be linked here once available.

Coming soon

References

Theoretical foundations

Theoretical results underlying the estimation and inference procedures implemented in sreg.

  1. Bugni, F. A., Canay, I. A., and Shaikh, A. M. (2018). Inference Under Covariate-Adaptive Randomization. Journal of the American Statistical Association.
  2. Bugni, F. A., Canay, I. A., and Shaikh, A. M. (2019). Inference under Covariate-Adaptive Randomization with Multiple Treatments. Quantitative Economics.
  3. Bugni, F. A., Canay, I. A., Shaikh, A. M., and Tabord-Meehan, M. (2025). Inference for Cluster Randomized Experiments with Non-ignorable Cluster Sizes. Journal of Political Economy Microeconomics.
  4. Jiang, L., Linton, O. B., Tang, H., and Zhang, Y. (2026). Improving Estimation Efficiency via Regression-Adjustment in Covariate-Adaptive Randomizations with Imperfect Compliance. Review of Economics and Statistics.
  5. Bai, Y., Jiang, L., Romano, J. P., Shaikh, A. M., and Zhang, Y. (2024). Covariate adjustment in experiments with matched pairs. Journal of Econometrics.
  6. Bai, Y. (2022). Optimality of Matched-Pair Designs in Randomized Controlled Trials. American Economic Review.
  7. Bai, Y., Romano, J. P., and Shaikh, A. M. (2022). Inference in Experiments With Matched Pairs. Journal of the American Statistical Association.
  8. Liu, J. (2026 revision). Inference for Two-stage Experiments under Covariate-Adaptive Randomization. Working paper, arXiv:2301.09016.
  9. Cytrynbaum, M. (2024). Covariate Adjustment in Stratified Experiments. Quantitative Economics.