I am wondering how to estimate the survival curve for a particular case(s) given a coxph model using this example code: #fit a cox proportional hazards model and plot the #predicted survival curve fit <- coxph( Surv(futime,fustat)~resid.ds+strata(rx)+ecog.ps+age,data=ovarian[1:23,]) z <- survfit(fit,newdata=ovarian[24:26,],individual=F) zs <- z$surv zt <- z$time I get the following output: 24 25 26 [1,] 0.9740399 0.91737529 0.9873785 [2,] 0.9431988 0.82552974 0.9721557 [3,] 0.9023088 0.71387936 0.9515702 [4,] 0.8518865 0.59121499 0.9255099 [5,] 0.7269607 0.35151309 0.8572808 [6,] 0.6130966 0.20108501 0.7895814 [7,] 0.2807720 0.01553603 0.5415119 [8,] 0.9159643 0.74991615 0.9584975 [9,] 0.8225510 0.52704511 0.9099799 [10,] 0.7058027 0.31906859 0.8451399 [1] 59 115 156 268 329 431 638 464 475 563 I am not sure what I am getting here, I was expecting to get three survival curves for each scenario in the "newdata" however the survival curves don't seem to be monotonically decreasing with time. I get the feeling that this has something to do with the use of strata(rx) in the model, but I am no sure how to sort it out. any help is appreciated, best regards, Spencer On 12/21/06, Blanchard, Suzette <SBlanchard@coh.org> wrote:> > Thank you for your help. With your fix I was able to get the correct > result once but then I would have to close R. > If I go back to R-2.3.1 Everything seem to work fine. Best to everyone > that helped. > Suzette > > ________________________________ > > From: Duncan Murdoch [mailto:murdoch@stats.uwo.ca] > Sent: Thu 12/21/2006 5:31 AM > To: Duncan Murdoch > Cc: Blanchard, Suzette; r-help@stat.math.ethz.ch > Subject: Re: [R] \Sexpr in MikTex > > > > Wow, that's a lot of errors in my post. Sorry about that. You should > probably just ignore it completely. > > Duncan Murdoch > > On 12/20/2006 10:05 PM, Duncan Murdoch wrote: > > On 12/20/2006 6:26 PM, Blanchard, Suzette wrote: > >> Greetings, \Sexpr{} has worked on MikTex with earlier versions of R, > I can not seem to get it to work with > >> R-2.4.0. I run Sweave with MikTex using the following statement in Run > under Accessories. > >> latex -include-directory="C:\Program Files\R\R-2.4.0\share\texmf" > "C:\Documents and Settings\Suzette\Desktop\MyFile\MyProgram.tex" > > > > There should be two hyphens in the option, i.e. --include-directory, > > shouldn't there? > > > > This should be automatically put in place if you used > > > > R CMD Sweave MyProgram.tex > > > > from a command line. > > > > Duncan Murdoch > > > >> > >> Any advice would be much appreciated, > >> Suzette > >> > >> > >> Suzette Blanchard, Ph.D. > >> Assistant Professor, Dept. of Biostatistics > >> City of Hope National Medical Center > >> and Beckman Research Institute > >> 1500 East Duarte Road, Duarte, CA 91010-3000 > >> sblanchard@coh.org <mailto:sblanchard@coh.org> > >> ph: (626) 256-4673 ext: 64446 > >> > >> > >> "EMF <COH.org>" made the following annotations. > >> > ------------------------------------------------------------------------------ > >> SECURITY/CONFIDENTIALITY WARNING: This message and any > atta...{{dropped}} > >> > >> ______________________________________________ > >> R-help@stat.math.ethz.ch 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. > > > > ______________________________________________ > > R-help@stat.math.ethz.ch 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. > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch 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. >[[alternative HTML version deleted]]
Charles C. Berry
2006-Dec-21 22:24 UTC
[R] : newbie estimating survival curve w/ survfit for coxph
Spencer, It always helps to look at the documentation for the objects you use. ?survfit.object tells you: ----------- COMPONENTS strata if there are multiple curves, this component gives the number of elements of the time etc. vectors corresponding to the first curve, the second curve, and so on. The names of the elements are labels for the curves. ----------- Note:> z$stratarx=1 rx=2 7 3>If it is still not obvious what gives, look at plot(z) then at z$time, z$strata, and z$surv. On Thu, 21 Dec 2006, sj wrote:> I am wondering how to estimate the survival curve for a particular case(s) > given a coxph model > > using this example code: > > #fit a cox proportional hazards model and plot the > #predicted survival curve > fit <- coxph( > Surv(futime,fustat)~resid.ds+strata(rx)+ecog.ps+age,data=ovarian[1:23,]) > z <- survfit(fit,newdata=ovarian[24:26,],individual=F) > zs <- z$surv > zt <- z$time > > I get the following output: > > 24 25 26 > [1,] 0.9740399 0.91737529 0.9873785 > [2,] 0.9431988 0.82552974 0.9721557 > [3,] 0.9023088 0.71387936 0.9515702 > [4,] 0.8518865 0.59121499 0.9255099 > [5,] 0.7269607 0.35151309 0.8572808 > [6,] 0.6130966 0.20108501 0.7895814 > [7,] 0.2807720 0.01553603 0.5415119 > [8,] 0.9159643 0.74991615 0.9584975 > [9,] 0.8225510 0.52704511 0.9099799 > [10,] 0.7058027 0.31906859 0.8451399 > > [1] 59 115 156 268 329 431 638 464 475 563 > > I am not sure what I am getting here, I was expecting to get three survival > curves for each scenario in the "newdata" however the survival curves don't > seem to be monotonically decreasing with time. I get the feeling that this > has something to do with the use of strata(rx) in the model, but I am no > sure how to sort it out. > > any help is appreciated, > > best regards, > > Spencer >[ irrelevant prior msg deleted ] Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717