Learn R Programming

MRTAnalysis (version 0.4.1)

calculate_mrt_effect_size: Calculate standardized proximal treatment effect across time (continuous outcomes)

Description

Estimates the time-varying standardized proximal causal excursion effect for **continuous** proximal outcomes in a micro-randomized trial. The estimator uses inverse-probability weighting and can adjust for baseline and time-varying covariates to improve efficiency. Optionally, the effect and scale estimates are smoothed over decision points using LOESS, and participant-level bootstrap confidence intervals can be computed.

Usage

calculate_mrt_effect_size(
  data,
  id,
  outcome,
  treatment,
  time,
  rand_prob,
  availability,
  covariates = NULL,
  smooth = TRUE,
  loess_span = 0.25,
  loess_degree = 1,
  do_bootstrap = TRUE,
  boot_replications = 1000,
  confidence_alpha = 0.05
)

Value

A data.frame of class "mrt_effect_size" containing the standardized effect for a continuous proximal outcome with columns:

time

Decision point index.

beta_hat

Raw (unsmoothed) estimated excursion effect at each time.

s_hat

Raw (unsmoothed) estimated outcome scale at each time.

beta_sm

Smoothed excursion effect across time (equals beta_hat if smooth = FALSE).

s_sm

Smoothed outcome scale across time (equals s_hat if smooth = FALSE).

estimate

Standardized effect beta_sm / s_sm.

lower

Lower confidence bound for estimate (NA if do_bootstrap = FALSE).

upper

Upper confidence bound for estimate (NA if do_bootstrap = FALSE).

Arguments

data

A data.frame of MRT data (see `data_example_for_standardized_effect`)

id

Column name for participant id

outcome

Column name for the continuous proximal outcome

treatment

Column name for treatment indicator

time

Column name for time / decision point

rand_prob

Column name for randomization probability

availability

Column name for availability indicator

covariates

Optional character vector of covariate column names

smooth

Logical; apply LOESS smoothing across time

loess_span

Numeric; smoother span

loess_degree

Numeric; polynomial degree in LOESS

do_bootstrap

Logical; whether to perform bootstrap over participants

boot_replications

Integer; number of bootstrap replications

confidence_alpha

Numeric; two-sided alpha level for CIs

References

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

Examples

Run this code
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   = c("covariate1", "covariate2"),
  do_bootstrap = TRUE,
  boot_replications = 100
)

# Note: use at least 1000 bootstrap replications for stable CIs.

summary(ans_ci)
plot(ans_ci)

Run the code above in your browser using DataLab