survminer
survminer copied to clipboard
Plotting the output of flexsurvreg
(e-mail from a user)
Is it possible that we could plot the output of flexsurvreg using survminer just as we do plot.flexsurvreg.
I'd love to have this too! Are you open to contributions?
Thanks, Peter.
Hi @lemna
Yes, contributions are welcome!! Thanks
@lemna are you working on this? If no, I'll work on it
I am - will do a PR in the coming days.
As I also needed this feature now, I've started to implemented it this morning. I'll push a commit in a second so that other can modify it.
First version of ggflexsurvplot()
available now:
if(!require("flexsurv")) install.packages("flexsurv")
devtools::install_github("kassambara/survminer")
library(survminer)
require("flexsurv")
fit <- flexsurvreg(Surv(rectime, censrec) ~ group,
dist = "gengamma", data = bc)
ggflexsurvplot(fit)
Thanks for adding the flexsurvreg functionality. When using ggflexsurvplot with a weibull a get the following error:
Error in .get_data(fit, data = data, complain = FALSE) :
The data
argument should be provided either to ggsurvfit or survfit.
Is there any way that we can plot all the distributions together along with the KM?
Lest no good deed go unpunished, it would be great to have the full set of ggsurvplot
variants available, especially ggsurvplot_facet
for models with multiple covariates.
I'm guessing the general solution would be a utility to translate the output objects from flexsurvreg
to the survfit
class. Not something I can do.
First version of
ggflexsurvplot()
available now:if(!require("flexsurv")) install.packages("flexsurv") devtools::install_github("kassambara/survminer") library(survminer) require("flexsurv") fit <- flexsurvreg(Surv(rectime, censrec) ~ group, dist = "gengamma", data = bc) ggflexsurvplot(fit)
This plot no longer works, even with groups as factors and add.all = FALSE. The resulting figure has strata = all added to the plot, and the KM curve is combined to one pooled curve with risk.table also pooled. Can someone please help to plot output of a stratified flexsurv object superimposed over stratified KM curves?
Output looks as follows: https://rpkgs.datanovia.com/survminer/reference/ggflexsurvplot.html
I'm having the same issue (all strata combined). I ended up building my own overlay ggplot from the KM and flexsurvreg outputs.
is it possible to separate strata KM and fit to separate plot or facet? ex:3 plots or facets for above plot.
First version of
ggflexsurvplot()
available now:if(!require("flexsurv")) install.packages("flexsurv") devtools::install_github("kassambara/survminer") library(survminer) require("flexsurv") fit <- flexsurvreg(Surv(rectime, censrec) ~ group, dist = "gengamma", data = bc) ggflexsurvplot(fit)
I did plot for recurrent event analysis with start, stop time in flexsurvreg then by using ggflexsurvplot. In this case, is it first event KM plot overlaid with first event model curve? OR it accounts for all events regardless of subject(counting method-anderson-gill method). I assume later is correct by checking code. can you please confirm?