View source: R/plot_sg_weighted_km.R
| plot_sg_weighted_km | R Documentation |
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
)
fs.est |
A forestsearch object containing |
fs_bc |
Optional. Bootstrap results from |
outcome.name |
Character. Name of time-to-event column.
Default: |
event.name |
Character. Name of event indicator column.
Default: |
treat.name |
Character. Name of treatment column.
Default: |
by.risk |
Numeric. Risk interval for plotting. Default: |
sg0_name |
Character. Label for H subgroup (treat.recommend == 0).
Default: |
sg1_name |
Character. Label for Hc subgroup (treat.recommend == 1).
Default: |
conf.int |
Logical. Show confidence intervals. Default: |
show.logrank |
Logical. Show log-rank test. Default: |
show.cox |
Logical. Show unadjusted Cox HR from weightedsurv.
Default: |
show.cox.bc |
Logical. Show bootstrap bias-corrected HR annotation
(requires |
put.legend.lr |
Character. Legend position. Default: "topleft" |
ymax |
Numeric. Max y-axis value. Default: 1.05 |
xmed.fraction |
Numeric. Fraction for median lines. Default: 0.65 |
hr_bc_position |
Character. Position for bias-corrected HR annotation. One of "bottomright", "bottomleft", "topright", "topleft". Default: "bottomright" |
hr_bc_cex |
Numeric. Character expansion factor for bias-corrected HR annotation text. Default: 0.725 (matches weightedsurv cox.cex default) |
title |
Character. Overall plot title. Default: |
verbose |
Logical. Print diagnostic messages. Default: |
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
Invisibly returns a list with subgroup data frames and counting data
## Not run:
# After running forestsearch - auto-extracts subgroup definition
plot_sg_weighted_km(fs.est = fs)
# With bootstrap bias-corrected estimates
plot_sg_weighted_km(fs.est = fs, fs_bc = fs_bootstrap)
# With custom column names
plot_sg_weighted_km(
fs.est = fs,
outcome.name = "time_months",
event.name = "status",
treat.name = "hormon"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.