0

I can not plot logistic or gaussian distributions fit to my data.

I load my data and create a survreg object

gbcs <- read.csv("https://ryanwomack.com/data/gbcs.csv")
recsurv <- Surv(rectime,censrec, gbcs)

If I try to fit a exponential distribution, It does not plot

fit_exp <- survreg(recsurv~1, dist="exponential")
plot(fit_exp)

Error in xy.coords(x, y, xlabel, ylabel, log) : 
'x' is a list, but does not have components 'x' and 'y'

Instead, when I use the package flexsurv, it plots easily

library(flexsurv)
fit_exp <- flexsurvreg(recsurv~1, dist="exp")
plot(fit_exp)

My point is: The flexsurv pack does not have some important distributions. How can I plot standard distributions fit with survreg() ?

  • We need data to reproduce. Try using `survfit` instead of `survreg`, then `plot`. – hmhensen Jan 24 '19 at 22:08
  • The data is public. gbcs <- read.csv("https://ryanwomack.com/data/gbcs.csv") – Fidel Alencar Jan 24 '19 at 23:53
  • survfit() does not work – Fidel Alencar Jan 25 '19 at 00:07
  • I don't know anything about this field, but this plots something: `fit_exp <- survfit(recsurv ~ 1, type="kaplan-meier", conf.type="log-log"); plot(fit_exp)`. – hmhensen Jan 25 '19 at 01:11
  • Try reading https://github.com/ryandata/Survival/blob/master/Survival.R and https://stackoverflow.com/questions/9151591/how-to-plot-the-survival-curve-generated-by-survreg-package-survival-of-r and https://stackoverflow.com/questions/45535882/plotting-a-survival-curve-from-a-survreg-prediction. It does not appear that you can directly plot an object produced by `survreg`. You'd first have to use `predict`. There are examples in the links. – hmhensen Jan 25 '19 at 01:12

0 Answers0