sreg: Estimate Average Treatment Effects (ATEs) and Corresponding...

View source: R/core.R

sregR Documentation

Estimate Average Treatment Effects (ATEs) and Corresponding Standard Errors

Description

Estimate the ATE(s) and the corresponding standard error(s) for a (collection of) treatment(s) relative to a control.

Usage

sreg(
  Y,
  S = NULL,
  D,
  G.id = NULL,
  Ng = NULL,
  X = NULL,
  HC1 = TRUE,
  small.strata = FALSE
)

Arguments

Y

a numeric n \times 1 vector/matrix/data.frame/tibble of the observed outcomes

S

a numeric n \times 1 vector/matrix/data.frame/tibble of strata indicators indexed by \{1, 2, 3, \ldots\}; if NULL then the estimation is performed assuming no stratification

D

a numeric n \times 1 vector/matrix/data.frame/tibble of treatments indexed by \{0, 1, 2, \ldots\}, where \code{D} = 0 denotes the control

G.id

a numeric n \times 1 vector/matrix/data.frame/tibble of cluster indicators; if NULL then estimation is performed assuming treatment is assigned at the individual level

Ng

a numeric n \times 1 vector/matrix/data.frame/tibble of cluster sizes; if NULL then Ng is assumed to be equal to the number of available observations in every cluster

X

a matrix/data.frame/tibble with columns representing the covariate values for every observation; if NULL then the estimator without linear adjustments is applied. (Note: sreg cannot use individual-level covariates for covariate adjustment in cluster-randomized experiments. Any individual-level covariates will be aggregated to their cluster-level averages)

HC1

a TRUE/FALSE logical argument indicating whether the small sample correction should be applied to the variance estimator

small.strata

a TRUE/FALSE logical argument indicating whether the estimators for small strata (i.e., strata with few units, such as matched pairs or n-tuples) should be used.

Value

An object of class sreg that is a list containing the following elements:

  • tau.hat: a 1 \times |\mathcal A| vector of ATE estimates, where |\mathcal A| represents the number of treatments

  • se.rob: a 1 \times |\mathcal A| vector of standard errors estimates, where |\mathcal A| represents the number of treatments

  • t.stat: a 1 \times |\mathcal A| vector of t-statistics, where |\mathcal A| represents the number of treatments

  • p.value: a 1 \times |\mathcal A| vector of corresponding p-values, where |\mathcal A| represents the number of treatments

  • CI.left: a 1 \times |\mathcal A| vector of the left bounds of the 95% as. confidence interval

  • CI.right: a 1 \times |\mathcal A| vector of the right bounds of the 95% as. confidence interval

  • data: an original data of the form data.frame(Y, S, D, G.id, Ng, X)

  • lin.adj: a data.frame representing the covariates that were used in implementing linear adjustments

  • small.strata: a TRUE/FALSE logical argument indicating whether the estimators for small strata (e.g., matched pairs or n-tuples) were used

  • HC1: a TRUE/FALSE logical argument indicating whether the small sample correction (HC1) was applied to the variance estimator

Author(s)

Authors:

Juri Trifonov jutrifonov@u.northwestern.edu

Yuehao Bai yuehao.bai@usc.edu

Azeem Shaikh amshaikh@uchicago.edu

Max Tabord-Meehan m.tabordmeehan@utoronto.ca

Maintainer:

Juri Trifonov jutrifonov@u.northwestern.edu

References

Bugni, F. A., Canay, I. A., and Shaikh, A. M. (2018). Inference Under Covariate-Adaptive Randomization. Journal of the American Statistical Association, 113(524), 1784–1796, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2017.1375934")}.

Bugni, F., Canay, I., Shaikh, A., and Tabord-Meehan, M. (2024+). Inference for Cluster Randomized Experiments with Non-ignorable Cluster Sizes. Forthcoming in the Journal of Political Economy: Microeconomics, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2204.08356")}.

Jiang, L., Linton, O. B., Tang, H., and Zhang, Y. (2023+). Improving Estimation Efficiency via Regression-Adjustment in Covariate-Adaptive Randomizations with Imperfect Compliance. Forthcoming in Review of Economics and Statistics, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2204.08356")}.

Bai, Y., Jiang, L., Romano, J. P., Shaikh, A. M., and Zhang, Y. (2024). Covariate adjustment in experiments with matched pairs. Journal of Econometrics, 241(1), \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jeconom.2024.105740")}.

Bai, Y. (2022). Optimality of Matched-Pair Designs in Randomized Controlled Trials. American Economic Review, 112(12), \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1257/aer.20201856")}.

Bai, Y., Romano, J. P., and Shaikh, A. M. (2022). Inference in Experiments With Matched Pairs. Journal of the American Statistical Association, 117(540), \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2021.1883437")}.

Liu, J. (2024). Inference for Two-stage Experiments under Covariate-Adaptive Randomization. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2301.09016")}.

Cytrynbaum, M. (2024). Covariate Adjustment in Stratified Experiments. Quantitative Economics, 15(4), 971–998, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3982/QE2475")}.

Examples

library("sreg")
library("dplyr")
library("haven")
### Example 1. Simulated Data.
data <- sreg.rgen(n = 1000, tau.vec = c(0), n.strata = 4, cluster = FALSE)
Y <- data$Y
S <- data$S
D <- data$D
X <- data.frame("x_1" = data$x_1, "x_2" = data$x_2)
result <- sreg(Y, S, D, G.id = NULL, Ng = NULL, X)
print(result)
### Example 2. Empirical Data.
?AEJapp
data("AEJapp")
data <- AEJapp
head(data)
Y <- data$gradesq34
D <- data$treatment
S <- data$class_level
data.clean <- data.frame(Y, D, S)
data.clean <- data.clean %>%
  mutate(D = ifelse(D == 3, 0, D))
Y <- data.clean$Y
D <- data.clean$D
S <- data.clean$S
table(D = data.clean$D, S = data.clean$S)
result <- sreg(Y, S, D)
print(result)
pills <- data$pills_taken
age <- data$age_months
data.clean <- data.frame(Y, D, S, pills, age)
data.clean <- data.clean %>%
  mutate(D = ifelse(D == 3, 0, D))
Y <- data.clean$Y
D <- data.clean$D
S <- data.clean$S
X <- data.frame("pills" = data.clean$pills, "age" = data.clean$age)
result <- sreg(Y, S, D, G.id = NULL, X = X)
print(result)
### Example 3. Matched Pairs (small strata).
data <- sreg.rgen(
  n = 1000, tau.vec = c(1.2), cluster = FALSE,
  small.strata = TRUE, k = 2, treat.sizes = c(1, 1)
)
Y <- data$Y
S <- data$S
D <- data$D
X <- data.frame("x_1" = data$x_1, "x_2" = data$x_2)
result <- sreg(Y = Y, S = S, D = D, X = X, small.strata = TRUE)
print(result)

sreg documentation built on Aug. 25, 2025, 5:14 p.m.