[R] Survival analysis

Sarah Goslee sarah.goslee at gmail.com
Thu Oct 20 23:05:58 CEST 2011


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.

Good luck,
Sarah

On Thu, Oct 20, 2011 at 3:22 PM, Cem Girit <girit at comcast.net> wrote:
>
> Hello Sarah,
>
>
>
>                 Thank you for useful reply. I now know how I can search R world. Google searchers were not useful.
>
>
>
>                 I have an efficacy study in which there are 1 control and 3 treatment groups. The survival event, date of events, and group data are in v, d, and g variables (see below). I am using the "Survival" package.  In SAS it is possible to calculate the mean and standard error of the survival times (see an example of SAS output (if it is viewed as html)).  I used the “survfit” function from this package together with the print or the summary options but I could not get any results for these parameters. Although, the print function help states that I should get the mean and the error and none of the examples in the print.survfit help file worked! I want to calculate these two parameters by any means in R.  Could you help me on this? Thank you.
>
>
>
>                 Sincerely,
>
> Cem
>
>
>
> Summary Statistics for Time Variable time
>
>
>
> Mean
>
> Standard Error
>
> 48.2222
>
> 2.6931
>
>
>
> > vT<-c(1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,0,0,0,0,1,0,1,0,0,0,1,0,0,1,1,1,0)
>
> > 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)
>
> > gT<-factor(c("Vehicle","Vehicle","Vehicle","Vehicle","Vehicle","Vehicle","Vehicle","Vehicle","Vehicle","DrugA","DrugA","DrugA","DrugA","DrugA","DrugA","DrugA","DrugA","DrugA","DrugB","DrugB","DrugB","DrugB","DrugB","DrugB","DrugB","DrugB","DrugB","DrugC","DrugC","DrugC","DrugC","DrugC","DrugC","DrugC","DrugC","DrugC"))
>
> > fit<-survfit(Surv(dT,vT)~gT)
>
> > fit
>
> Call: survfit(formula = Surv(dT, vT) ~ gtT)
>
>
>
>             records n.max n.start events median 0.95LCL 0.95UCL
>
> gtT=DrugA         9     9       9      6     48      45      NA
>
> gtT=DrugB         9     9       9      3     NA      43      NA
>
> gtT=DrugC         9     9       9      4     NA      47      NA
>
> gtT=Vehicle       9     9       9      8     40      38      NA
>
> > print(fit,print.n=getOption("survfit.print.n"), show.rmean=getOption("survfit.print.mean"))
>
> Call: survfit(formula = Surv(dT, vT) ~ gtT)
>
>
>
>             records n.max n.start events median 0.95LCL 0.95UCL
>
> gtT=DrugA         9     9       9      6     48      45      NA
>
> gtT=DrugB         9     9       9      3     NA      43      NA
>
> gtT=DrugC         9     9       9      4     NA      47      NA
>
> gtT=Vehicle       9     9       9      8     40      38      NA
>
>
>
> > summary(fit)
>
> Call: survfit(formula = Surv(dT, vT) ~ gtT)
>
>
>
>                 gtT=DrugA
>
>  time n.risk n.event survival std.err lower 95% CI upper 95% CI
>
>    32      9       1    0.889   0.105        0.706        1.000
>
>    43      8       1    0.778   0.139        0.549        1.000
>
>    45      7       1    0.667   0.157        0.420        1.000
>
>    46      6       1    0.556   0.166        0.310        0.997
>
>    48      5       1    0.444   0.166        0.214        0.923
>
>    55      3       1    0.296   0.164        0.100        0.875
>
>
>
>                 gtT=DrugB
>
>  time n.risk n.event survival std.err lower 95% CI upper 95% CI
>
>    42      9       2    0.778   0.139        0.549            1
>
>    43      7       1    0.667   0.157        0.420            1
>
>
>
>                 gtT=DrugC
>
>  time n.risk n.event survival std.err lower 95% CI upper 95% CI
>
>    42      9       1    0.889   0.105        0.706        1.000
>
>    43      8       1    0.778   0.139        0.549        1.000
>
>    47      7       2    0.556   0.166        0.310        0.997
>
>
>
>                 gtT=Vehicle
>
>  time n.risk n.event survival std.err lower 95% CI upper 95% CI
>
>    37      9       2    0.778   0.139       0.5485        1.000
>
>    38      7       2    0.556   0.166       0.3097        0.997
>
>    40      5       1    0.444   0.166       0.2141        0.923
>
>    41      4       1    0.333   0.157       0.1323        0.840
>
>    44      3       1    0.222   0.139       0.0655        0.754
>
>    45      2       1    0.111   0.105       0.0175        0.705
>
>
>
>
>
>
>
> Cem
>
>
>
> Cem Girit
>
>
>
> 56 Marion Drive
>
> Plainsboro, NJ 08536
>
> Tel: (609) 275 0321
>
> Email:girit at comcast.net
>
> -----Original Message-----
> From: Sarah Goslee [mailto:sarah.goslee at gmail.com]
> Sent: Thursday, October 20, 2011 2:20 PM
> To: Cem Girit
> Cc: r-help at r-project.org
> Subject: Re: [R] Survival analysis
>
>
>
> Hi,
>
>
>
>
>
> On Thu, Oct 20, 2011 at 2:04 PM, Cem Girit <girit at biopticon.com> wrote:
>
> > Hello,
>
> >
>
> >
>
> >
>
> >                I need some results from the survival analysis of my
>
> > data that I do not know whether exist in Survival Package or how to
>
> > obtain if they do:
>
> >
>
> >
>
> >
>
> > 1.       The Mean survival time
>
> >
>
> > 2.       The standard error of the mean
>
> >
>
> > 3.       Point and 95% Lower & Upper Confidence Intervals estimates
>
> >
>
> >
>
> >
>
> > Any help will be greatly appreciated.
>
> >
>
>
>
>
>
> Since we don't know anything about your data or what you've tried, probably the best thing for you to do is do some reading on your own, then come back to the list when you have a specific question.
>
>
>
> If you go to www.rseek.org and search for survival analysis, you will find a great deal of R information on that topic. It's a good place to start.
>
>
>
> Sarah
>
> --
>
> Sarah Goslee
>
> http://www.functionaldiversity.org


--
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org



More information about the R-help mailing list