[R] Problem using pkg "survival"

peter dalgaard pdalgd at gmail.com
Mon Dec 27 20:44:35 CET 2010


On Dec 27, 2010, at 19:48 , James Steinberg wrote:

> Hello all.
> 
> I've been attempting to utilize the "survival" pkg (
> http://cran.r-project.org/web/packages/survival/index.html), while reading
> through this guide (http://www.ms.uky.edu/~mai/Rsurv.pdf). I figured working
> through the guide would be the best way to go, before attempting my own
> data.
> 
> I tried to utilize the Kaplain-Meier estimator as shown in the guide:
>       summary(survfit(Surv(aml$time[1:11],aml$status[1:11])))
> 
> This, however, returns the error:
> 
>        Error in survfit(Surv(aml$time[1:11], aml$status[1:11])) :
>  Survfit requires a formula or a coxph fit as the first argument
> 
> Obviously the first thing that throws me is that apparently the package's
> guide doesn't actually work with the package. That seems a glaring
> oversight, so my first thought is obviously that I've missed
> a setting somewhere.

Well, 

1) Welcome to the Internet. Information given here may be incorrect or out of date. Let the buyer beware.

2) Unfortunately, documents (or books) do not automagically update themselves when the software changes. 

The document in question appears to be course material for a course given by Dr. Mai Zhou in 2009, at which time the information may have been accurate. It is not in any sense "the package's guide" since Dr. Zhou is not in charge of the development or maintenance of the survival package.

Anyways, the main point is that the author of the survival package has decided that survfit should no longer be allowed to be a Surv() object only. It needs to be a model formula, and if there are no covariates, use survfit(Surv(....) ~ 1). This is mentioned on the help page for survfit.


> 
> I then tried to provide a function for survfit, as requested, but I could no
> x-axis variable for the function (assuming Surv[] is the response variable)
> that would make it work.
> 
> Any ideas/suggestions?
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list