Learn R Programming

⚠️There's a newer version (0.4.1) of this package.Take me there.

MRTAnalysis

The MRTAnalysis package provides functions to conduct post-study analyses of Micro-Randomized Trials (MRTs), focusing on estimating causal excursion effects.

  • Proximal outcomes (measured shortly after each treatment decision point):

    • wcls(): Primary analysis for continuous proximal outcomes. Implements weighted and centered least squares (the $k=1$ special case of Boruvka et al., 2018).
    • emee(): Primary analysis for binary proximal outcomes. Implements the estimator for marginal excursion effect (the $\Delta=1$ special case of Qian et al., 2021).
    • emee2(): Variant of emee(), centering treatment in the residual term. Basis for the sample size calculator in MRTSampleSizeBinary.
  • Distal outcomes (measured once at end of study):

    • dcee(): Exploratory analysis for distal causal excursion effects in MRTs (Qian et al. 2025). Supports linear models and machine-learning learners (lm, gam, random forest, ranger, SuperLearner) with optional cross-fitting.

Installation

You can install the package from CRAN:

install.packages("MRTAnalysis")

Usage

See vignettes for detailed examples:

library(MRTAnalysis)

# Proximal outcome analysis (continuous)
fit1 <- wcls(
  data = data_mimicHeartSteps,
  id = "userid", outcome = "logstep_30min",
  treatment = "intervention", rand_prob = 0.6,
  moderator_formula = ~1,
  control_formula = ~logstep_pre30min,
  availability = "avail"
)
summary(fit1)

# Distal outcome analysis
fit2 <- dcee(
  data = data_distal_continuous,
  id = "userid", outcome = "Y",
  treatment = "A", rand_prob = "prob_A",
  moderator_formula = ~1,
  control_formula = ~X,
  availability = "avail",
  control_reg_method = "lm"
)
summary(fit2)

References

  • Boruvka, A., Almirall, D., Witkiewitz, K., & Murphy, S. A. (2018). Assessing time-varying causal effect moderation in mobile health. Journal of the American Statistical Association, 113(523), 1112–1121. doi:10.1080/01621459.2017.1305274

  • Qian, T., Yoo, H., Klasnja, P., Almirall, D., & Murphy, S. A. (2021). Estimating time-varying causal excursion effects in mobile health with binary outcomes. Biometrika, 108(3), 507–527. doi:10.1093/biomet/asaa070

  • Qian, T. (2025). Distal Causal Excursion Effects: Modeling Long-Term Effects of Time-Varying Treatments in Micro-Randomized Trials. arXiv:2502.13500.

Copy Link

Version

Install

install.packages('MRTAnalysis')

Monthly Downloads

301

Version

0.2.0

License

GPL-3

Maintainer

Tianchen Qian

Last Published

August 29th, 2025

Functions in MRTAnalysis (0.2.0)

data_distal_continuous

A synthetic data set of an MRT with continuous distal outcome
dcee

Distal Causal Excursion Effect (DCEE) Estimation
emee2

Estimates the causal excursion effect for binary outcome MRT
wcls

Estimates the causal excursion effect for continuous outcome MRT
summary.dcee_fit

Summary for DCEE fits
summary.emee_fit

Summarize Causal Excursion Effect Fits for MRT with Binary Outcomes
summary.wcls_fit

Summarize Causal Excursion Effect Fits for MRT with Continuous Outcomes
emee

Estimates the causal excursion effect for binary outcome MRT
data_mimicHeartSteps

A synthetic data set that mimics the HeartSteps V1 data structure to illustrate the use of [wcls()] function for continuous proximal outcomes
data_binary

A synthetic data set of an MRT with binary proximal outcomes