View source: R/plot_effect_distribution.R
| plot_effect_distribution | R Documentation |
Builds a three-panel violin plot (ITT / identified \hat H /
identified \hat H^c) of treatment-effect estimates across
simulation replicates produced by
run_simulation_analysis(). Handles both GLM endpoints
(OR, RD, IRR) and survival (HR), optionally inverts effects to a
benefit scale (subgroup_notation = "benefit"), and overlays a
dotted reference line at the DGM-implied true effect in \hat H.
plot_effect_distribution(
results,
analysis_method = "FS",
effect_measure = c("OR", "HR", "RD", "IRR", "MD"),
subgroup_notation = c("harm", "benefit"),
reference_effect = NA_real_,
title = NULL,
subtitle = NULL,
panel_labels = NULL,
drop_undetected = TRUE,
trim_threshold = 1000,
trim_fraction = 0.01,
ylim = NULL
)
results |
|
analysis_method |
Character. Method label in the
|
effect_measure |
Character. One of |
subgroup_notation |
Character. |
reference_effect |
Numeric or |
title |
Character. Plot title. Default: auto-constructed. |
subtitle |
Character or |
panel_labels |
Named character vector with names |
drop_undetected |
Logical. Restrict the |
trim_threshold |
Numeric or |
trim_fraction |
Numeric in (0, 0.5). Fraction of observations
to trim from each tail of each group when trimming triggers.
Default: |
ylim |
Numeric vector of length 2 or |
The MRCT analogue is SGplot_estimates, which works on
the four-panel mrct_region_sims() schema (ITT / training /
testing / subgroup). This function targets the three-panel
run_simulation_analysis() schema that does not involve a
train/test split.
A ggplot2 object. Has attr(p, "panel_data")
set to the long-format data.table used for plotting (for
downstream summaries or diagnostic inspection). When trimming is
active, also has attr(p, "trim_info") containing per-group
diagnostics (n_total, n_trimmed, n_flagged,
raw_mean, raw_sd, trimmed_mean,
trimmed_sd, lower_bound, upper_bound).
run_simulation_analysis for the simulation
pipeline, SGplot_estimates for the MRCT analogue,
build_estimation_table for the tabular counterpart.
## Not run:
# Binary endpoint, benefit search, OR scale
true_or_benefit <- 1 / dgm_calibrated$hazard_ratios$harm_subgroup
p <- plot_effect_distribution(
results_alt,
analysis_method = "FS",
effect_measure = "OR",
subgroup_notation = "benefit",
reference_effect = true_or_benefit,
title = "ACTG175 Binary (HTE): OR Estimates Across Simulations",
subtitle = sprintf("n = 1000, 50 sims | truth OR(Q) = %.2f",
true_or_benefit)
)
print(p)
# Survival endpoint, harm search, HR scale (no inversion)
p_surv <- plot_effect_distribution(
results_alt,
effect_measure = "HR",
subgroup_notation = "harm",
reference_effect = dgm_alt$hazard_ratios$harm_subgroup
)
# Clip y-axis to focus on the interesting OR range
p_clipped <- plot_effect_distribution(
results_alt,
effect_measure = "OR",
subgroup_notation = "benefit",
reference_effect = true_or_benefit,
ylim = c(0, 4)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.