View source: R/calculate_mrt_effect_size.R
| calculate_mrt_effect_size | R Documentation |
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.
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
)
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 |
A data.frame of class "mrt_effect_size" containing the
standardized effect for a continuous proximal outcome with columns:
Decision point index.
Raw (unsmoothed) estimated excursion effect at each time.
Raw (unsmoothed) estimated outcome scale at each time.
Smoothed excursion effect across time (equals beta_hat
if smooth = FALSE).
Smoothed outcome scale across time (equals s_hat
if smooth = FALSE).
Standardized effect beta_sm / s_sm.
Lower confidence bound for estimate (NA if
do_bootstrap = FALSE).
Upper confidence bound for estimate (NA if
do_bootstrap = FALSE).
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.