[R] Survival analysis

David Winsemius dwinsemius at comcast.net
Fri Oct 21 00:25:07 CEST 2011


On Oct 20, 2011, at 5:05 PM, Sarah Goslee wrote:

> Hi,
>
> Please send your information to the r-help list, not just to me, but  
> do
> note that the list is plain-text only.
>
> But surely all you are looking for is:
>> dt<- 
>> c 
>> (37,41,40,38,38,37,44,45,48,43,48,46,54,60,32,45,55,62,42,62,62,62,47,42,59,43,60,60,51,43,50,51,47,42,47,51 
>> )
>> mean(dt)
> [1] 48.16667
>> sd(dt)/sqrt(length(dt))
> [1] 1.404923
>
> I have no idea what bizarre formula SAS uses to calculate standard  
> error,
> but the means match.
>
> And you'll note that the lengthy R output you pasted in works just  
> fine,
> and *does* include the standard errors and confidence limits *of the
> groups you specified* in your formula. Maybe one of the excellent
> introduction to R guides available online would be of use to you.

I suspect that Cem Girit is attempting to use survival::survfit and  
survival::print.survfit, to get group means.  (He also spelled his vT  
variable differently in two places.)  He seems confused about how to  
offer arguments to the print.rmean and rmean paramters. He had been  
advised by Therneau to read:

?print.survfit   # where the details of the rmean calculation are  
discussed

Both parameters are expecting a value of TRUE to be invoked, and he  
was both misnaming them and mis-specifying them. Their default values  
are:

 > getOption('survfit.rmean')
NULL
 > getOption("survfit.print.rmean")
NULL

After changing the name of "vt" to "vT":

 > print(fit,print.rmean=TRUE)
Call: survfit.formula(formula = Surv(dT, vT) ~ gT)

            records n.max n.start events *rmean *se(rmean) median  
0.95LCL 0.95UCL
gT=DrugA         9     9       9      6   50.0       3.11     48       
45      NA
gT=DrugB         9     9       9      3   54.8       2.93     NA       
43      NA
gT=DrugC         9     9       9      4   53.8       2.74     NA       
47      NA
gT=Vehicle       9     9       9      8   42.3       2.38     40       
38      NA
     * restricted mean with upper limit =  61

If an overall rmean were desired it would be obtained thusly:

 > print(fit,print.rmean=TRUE)
Call: survfit.formula(formula = Surv(dT, vT) ~ 1)

    records      n.max    n.start     events     *rmean *se(rmean)      
median
       36.0       36.0       36.0       21.0       50.5         
1.7       47.0
    0.95LCL    0.95UCL
       43.0         NA
     * restricted mean with upper limit =  62


-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list