Creates weighted Kaplan-Meier survival curves for the identified subgroups
(H and Hc) using the weightedsurv package, matching the pattern used in
sg_consistency_out().
plot_sg_weighted_km(
fs.est,
fs_bc = NULL,
outcome.name = "Y",
event.name = "Event",
treat.name = "Treat",
by.risk = NULL,
sg0_name = NULL,
sg1_name = NULL,
conf.int = TRUE,
show.logrank = TRUE,
show.cox = TRUE,
show.cox.bc = TRUE,
put.legend.lr = "topleft",
ymax = 1.05,
xmed.fraction = 0.65,
hr_bc_position = "bottomright",
hr_bc_cex = 0.725,
title = NULL,
verbose = FALSE
)Invisibly returns a list with subgroup data frames and counting data
A forestsearch object containing df.est with
treat.recommend column, or a data frame directly.
Optional. Bootstrap results from forestsearch_bootstrap_dofuture()
containing bias-corrected HR estimates. If provided, bias-corrected HRs
will be annotated on the plots.
Character. Name of time-to-event column.
Default: "Y"
Character. Name of event indicator column.
Default: "Event"
Character. Name of treatment column.
Default: "Treat"
Numeric. Risk interval for plotting. Default: NULL
(auto-calculated as max(outcome)/12)
Character. Label for H subgroup (treat.recommend == 0).
Default: NULL (auto-extracted from forestsearch object as
"H: {definition}" or "Questionable (H)" if not available)
Character. Label for Hc subgroup (treat.recommend == 1).
Default: NULL (auto-generated as "Hc: NOT {definition}" or
"Recommend (Hc)" if not available)
Logical. Show confidence intervals. Default: TRUE
Logical. Show log-rank test. Default: TRUE
Logical. Show unadjusted Cox HR from weightedsurv.
Default: TRUE
Logical. Show bootstrap bias-corrected HR annotation
(requires fs_bc). Default: TRUE
Character. Legend position. Default: "topleft"
Numeric. Max y-axis value. Default: 1.05
Numeric. Fraction for median lines. Default: 0.65
Character. Position for bias-corrected HR annotation. One of "bottomright", "bottomleft", "topright", "topleft". Default: "bottomright"
Numeric. Character expansion factor for bias-corrected HR annotation text. Default: 0.725 (matches weightedsurv cox.cex default)
Character. Overall plot title. Default: NULL
Logical. Print diagnostic messages. Default: FALSE
This function uses the exact same calling pattern as plot_subgroup()
in the ForestSearch package. Column names are mapped internally to the
standard names (Y, Event, Treat) expected by weightedsurv.
Subgroup definitions are automatically extracted from the forestsearch object if available:
fs$grp.consistency$out_sg$sg.harm_label - Human-readable labels
fs$sg.harm - Technical factor names (fallback)
HR display options controlled by show.cox and show.cox.bc:
Both TRUE (default): Shows unadjusted HR from weightedsurv AND bias-corrected HR annotation
show.cox = TRUE, show.cox.bc = FALSE: Shows only unadjusted HR
show.cox = FALSE, show.cox.bc = TRUE: Shows only bias-corrected HR
Both FALSE: Shows neither HR estimate