RCTCovAdj

RCTCovAdj implements covariate-adjusted estimation and study-design tools for two-arm randomized controlled trials with continuous outcomes. It accompanies the paper Semiparametric Efficiency Theory for Covariate Adjustment in Randomized Controlled Trials, reproduces its simulation and study-design calculations, and provides the code for its real-data application.

The package provides:

Installation

After release on CRAN, install the package with

install.packages("RCTCovAdj")

To install a source bundle downloaded from the project, run

install.packages("RCTCovAdj_0.1.0.tar.gz", repos = NULL, type = "source")

A quick analysis

library(RCTCovAdj)

set.seed(20260904)
n <- 600L
x <- rnorm(n)
a <- rbinom(n, 1L, 0.5)
y <- 0.5 * a + (2 - 3 * a) * x + rnorm(n)

rct_adjust(
  outcome = y,
  treatment = a,
  covariates = data.frame(x = x),
  allocation = 0.5,
  methods = c("unadjusted", "ancova", "interacted")
)

Supply the treatment probability specified by the randomization design through allocation. The interacted analysis fits treatment-specific regressions, standardizes their contrast over the full empirical covariate distribution, and uses an influence-function variance that includes variation from this standardization.

A cross-fitted analysis uses held-out predictions:

rct_crossfit(
  outcome = y,
  treatment = a,
  covariates = data.frame(x = x),
  allocation = 0.5,
  learner = "linear",
  folds = 2L,
  seed = 2718L
)

Power and sample size

rct_sample_size(
  effect = 0.5,
  variance = c(unadjusted = 12.5, interacted = 8.5, efficient = 4),
  power = 0.80,
  alpha = 0.05,
  alternative = "two.sided"
)

At a common effect, allocation, significance level, test alternative, and target power, continuous normal-approximation sample-size ratios equal the corresponding influence-function variance ratios. Integer totals are rounded upward.

Reproducing the paper

The installed data objects include simulation_cases, paper_simulation_results, paper_population_benchmarks, and paper_power_design_results. A full Monte Carlo run uses 4,000 replications in each of eight case–sample-size cells:

output_dir <- tempfile("rctcovadj-full-")
reproduce_paper_simulations(
  output_dir = output_dir,
  reps = 4000L,
  sample_sizes = c(200L, 800L),
  seed = 20260903L
)

Remove temporary results with unlink(output_dir, recursive = TRUE) after inspection. Replace the temporary directory with the intended permanent destination. This command is computationally intensive. The installed aggregate simulation summaries permit the corresponding figures and tables to be rebuilt without rerunning it. See the package vignettes for a short executable example, the exact simulation laws, and a structured reproducibility audit. Standalone replication workflows record session information and file checksums with their outputs.

vignette("covariate-adjustment", package = "RCTCovAdj")
vignette("reproducing-paper", package = "RCTCovAdj")

Trial-data availability

Neither the participant-level licorice-gargle trial records nor results derived from them are included. The source portal states that permission from the data contributor or corresponding author is required before the records are used in a new publication. Installing this package grants no right to analyze, publish, or redistribute the records or derived outputs.

Users who have obtained an authorized copy can verify and analyze it locally:

licorice <- read_licorice_data(file.choose())
licorice_fit <- analyze_licorice(licorice)
licorice_fit$estimates
plot_licorice_results(licorice_fit)

The optional medicaldata package provides another source-format copy. Its availability does not establish permission for a proposed use. After reviewing the governing terms and obtaining the required permission, a user can construct the reviewed analysis object with prepare_licorice_data() and pass it to analyze_licorice().

The real-data calculations concern records with an observed outcome and do not, without additional missing-outcome assumptions, identify an effect among all randomized participants.