Skip to content
Prev 59639 / 398503 Next

Weibull survival regression

On Tue, 23 Nov 2004, Eric Lim wrote:

            
Yes. There isn't a plot method for survreg() (and if there were, it 
wouldn't do this).

The right thing to try would have been
   plot(survfit(lung.wbs)
but that doesn't work either.

You can get the curve you want with
   curve(pweibull(x, scale=exp(coef(lung.wbs)), shape=1/lung.wbs$scale,
    lower.tail=FALSE),from=0, to=max(lung$futime))

where most of the complications come from the fact that survreg() and 
pweibull() parametrise the Weibull distribution differently.

Incidentally, this works quite nicely on the built-in lung cancer example 
data set, showing surprisingly good fit to a Weibull.

   data(lung)
   lung.wbs <- survreg( Surv(time, status)~ 1, data=lung, dist='weibull')
   curve(pweibull(x, scale=1/coef(lung.wbs), shape=1/lung.wbs$scale,
      lower.tail=FALSE),from=0, to=max(lung$time))
   lines(survfit(Surv(time,status)~1, data=lung), col="red")


 	-thomas