Skip to content

Plot survreg model #276

@HeidiSeibold

Description

@HeidiSeibold

It would be nice to be able to plot survreg models with your functions.

See e.g. this question on SO: https://stackoverflow.com/questions/43347376/include-weibull-fit-in-ggsurvplot

Creating a data.frame as from surv_summary does not help since the plot will still be shown as a step function.

## use data generating code from SO link
library("survival")
wbmod <- survreg(Surv(time, status) ~ x, data = dat)
s <- seq(.01, .99, by = .01)
t_0 <- predict(wbmod, newdata = data.frame(x = 0), 
                 type = "quantile", p = s)
t_1 <- predict(wbmod, newdata = data.frame(x = 1), 
                type = "quantile", p = s)

smod <- data.frame(time = c(t_0, t_1), 
                   surv = rep(1 - s, times = 2), 
                   strata = rep(c(0, 1), each = length(s)),
                   upper = NA, lower = NA)

library("survminer")
ggsurvplot(smod)  

rplot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions