| weightedsurv-package | R Documentation |
Provides functions for weighted and stratified survival analysis, including Cox proportional hazards models, weighted log-rank tests, Kaplan-Meier curves, and RMST calculations with various weighting schemes.
df_counting: Main function for weighted survival analysis
KM_diff: Kaplan-Meier difference calculations
cox_rhogamma: Weighted Cox model with flexible weights
plot_weight_schemes: Visualize weighting schemes
cumulative_rmst_bands: RMST analysis with confidence bands
The package supports multiple weighting schemes for log-rank tests:
Fleming-Harrington (fh): Emphasizes early or late differences
Magirr-Burman (MB): Modest downweighting after cutoff time
Schemper: Adjusts for censoring distribution
Xu-O'Quigley (XO): Adjusts for risk set size
Custom time-based weights
Prepare data with treatment (0/1), time-to-event, and event indicator
Run df_counting() for comprehensive analysis
Use plot_weighted_km() to visualize survival curves
Calculate survival differences with KM_diff()
Perform weighted Cox regression with cox_rhogamma()
Compute RMST with cumulative_rmst_bands()
Flexible weighting schemes for hypothesis testing
Resampling-based inference for improved small-sample properties
Simultaneous confidence bands for survival curves
Stratified analysis support
Weighted observations
Comprehensive diagnostic checks
Maintainer: Larry Leon larry.leon.05@post.harvard.edu
Fleming, T. R. and Harrington, D. P. (1991). Counting Processes and Survival Analysis. Wiley.
Magirr, D. and Burman, C. F. (2019). Modestly weighted logrank tests. Statistics in Medicine, 38(20), 3782-3790.
Useful links:
Report bugs at https://github.com/larry-leon/weightedsurv/issues
library(survival)
str(veteran)
veteran$treat <- as.numeric(veteran$trt) - 1
# Basic analysis
result <- df_counting(
df = veteran,
tte.name = "time",
event.name = "status",
treat.name = "treat"
)
# Plot results
plot_weighted_km(result)
# Weighted log-rank emphasizing late differences
result_fh <- df_counting(
df = veteran,
tte.name = "time",
event.name = "status",
treat.name = "treat",
scheme = "fh",
scheme_params = list(rho = 0, gamma = 1)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.