MyNixOS website logo
Description

Assessing Proximal, Distal, and Mediated Causal Excursion Effects for Micro-Randomized Trials.

Provides methods to analyze micro-randomized trials (MRTs) with binary treatment options. Supports four types of analyses: (1) proximal causal excursion effects, including weighted and centered least squares (WCLS) for continuous proximal outcomes by Boruvka et al. (2018) <doi:10.1080/01621459.2017.1305274> and the estimator for marginal excursion effect (EMEE) for binary proximal outcomes by Qian et al. (2021) <doi:10.1093/biomet/asaa070>; (2) distal causal excursion effects (DCEE) for continuous distal outcomes using a two-stage estimator by Qian (2025) <doi:10.1093/biomtc/ujaf134>; (3) mediated causal excursion effects (MCEE) for continuous distal outcomes, estimating natural direct and indirect excursion effects in the presence of time-varying mediators by Qian (2025) <doi:10.48550/arXiv.2506.20027>; and (4) standardized proximal effect size estimation for continuous proximal outcomes, generalizing the approach in Luers et al. (2019) <doi:10.1007/s11121-017-0862-5> to allow adjustment for baseline and time-varying covariates for improved efficiency.

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.
  • Mediated effects through time-varying mediators to distal outcomes:

    • mcee(): Exploratory analysis for mediated causal excursion effects in MRTs, estimating natural direct excursion effects (NDEE) and natural indirect excursion effects (NIEE) through time-varying mediators. Supports GLM, GAM, random forest, ranger, and SuperLearner learners for fitting nuisance parameters.
  • Standardized proximal effect size (continuous proximal outcomes only):

    • calculate_mrt_effect_size(): Standardized proximal effect size estimation for continuous proximal outcomes, with optional smoothing and bootstrap CIs.

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)

# Mediation with distal outcome
fit3 <- mcee(
  data = data_time_varying_mediator_distal_outcome,
  id = "id", dp = "dp",
  outcome = "Y", treatment = "A", mediator = "M",
  availability = "I", rand_prob = "p_A",
  time_varying_effect_form = ~1,                # constant effects over time
  control_formula_with_mediator = ~ dp + M + X, # adjustment set
  control_reg_method = "glm"
)
summary(fit3)

# Standardized proximal effect size (continuous proximal outcomes only)
data("data_example_for_standardized_effect")
ans_ci <- calculate_mrt_effect_size(
  data = data_example_for_standardized_effect,
  id = "id",
  outcome = "outcome",
  treatment = "treatment",
  time = "decision_point",
  rand_prob = "prob_treatment",
  availability = "availability",
  covariates = "covariate1",
  do_bootstrap = TRUE,
  boot_replications = 100
)
# Note: use at least 1000 bootstrap replications for stable CIs.
summary(ans_ci)
plot(ans_ci)

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. Biometrics, 81(4), ujaf134.

  • Qian, T. (2025). Dynamic Causal Mediation Analysis for Intensive Longitudinal Data. arXiv:2506.20027.

  • Luers, B., Klasnja, P., & Murphy, S. (2019). Standardized effect sizes for preventive mobile health interventions in micro-randomized trials. Prevention Science, 20(1), 100–109.

Metadata

Version

0.4.1

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows