[R] Weibull survival regression

Göran Broström gb at stat.umu.se
Tue Nov 23 12:59:40 CET 2004


On Tue, Nov 23, 2004 at 06:56:56AM -0000, Eric Lim wrote:
> Dear R users,
>  
> Please can you help me with a relatively straightforward problem that I
> am struggling with? I am simply trying to plot a baseline survivor and
> hazard function for a simple data set of lung cancer survival where
> `futime' is follow up time in months and status is 1=dead and 0=alive.
>  
> Using the survival package:
>  
> lung.wbs <- survreg( Surv(futime, status)~ 1, data=lung, dist='weibull')
>  
> plot (lung.wbs)
>  
> Returns the error msg:
>  
> Error in xy.coords(x, y, xlabel, ylabel, log) : 
>         x and y lengths differ
>  
> Using the Design package:
>  
> lung.wbd <- psm (Surv (futime, status)~ 1, dist="weibull", data=lung,
> na.action=na.omit)
>  
> survplot(lung.wbd)
>  
> Returns the error msg:
>  
> Error in survplot.Design(lung.wbd) : fit does not have design
> information
>  
> Using the eha package (I have not figured out how to get baseline
> function only, but have used ht=0/1 hypertension as a covariate):
>  
> lung.wbe <- weibreg (Surv (futime, status)~ ht, y=T, data=audit,
> na.action=na.omit)
>  
> plot (lung.wbe)
>  
> I get a plot with hazard (y) against age (x) ??? I cannot control the
> axes with labeling and any other covariate gets the same plot.

Right, plot.weibreg in eha is very poorly implemented, newdata does not
work, you cannot change labels of the plot, etc. I hope to get time to do
it right soon, but...

Anyway, the problem is simple to solve: You get the estimates of scale and
shape of the Weibull distribution (or their logarithms). Since eha uses
"standard R parametrization", you can simply plot the functions 
"dweibull / pweibull( , lower.tail = FALSE)" with the estimated parameters
inserted for the hazard function, and "pweibull( , lower.tail = FALSE)" for
the survival function.

[...]

Göran


-- 
 Göran Broström                    tel: +46 90 786 5223
 Department of Statistics          fax: +46 90 786 6614
 Umeå University                   http://www.stat.umu.se/egna/gb/
 SE-90187 Umeå, Sweden             e-mail: gb at stat.umu.se




More information about the R-help mailing list