chjackson / flexsurv

The flexsurv R package for flexible parametric survival and multi-state modelling
http://chjackson.github.io/flexsurv/
54 stars 28 forks source link

Account for case weights in survival and cumulative hazard KM plots #81

Closed andbe closed 4 years ago

andbe commented 4 years ago

The Kaplan Meier produced by plot.flexsurvreg do not account for case weights. While this issue can be easily worked around, the plots can be misleading as all cases are associated to unit weights, and weighted KM are expected by users.

As all flexsurvreg objects include case weights in $data$m$`(weights)` this can be added easily to the type == "survival" and type == "cumhaz" options in plot.flexsurvreg. The muhaz function used in type == "hazard" does not have a built-in functionality accounting for case weights, and is not modified in this pull request.

chjackson commented 4 years ago

Thanks for the contribution!