Skip to content

plot(survfit(fitCox)) graph shows one line - should show two

3 messages · John Sorkin, Greg Finak, Thomas Lumley

#
R 2.8.1
Windows XP

I am trying to plot the results of a coxph using plot(survfit()). The plot should, I believe, show two lines one for survival in each of two treatment (Drug) groups, however my plot shows only one line. What am I doing wrong?

My code is reproduced below, my figure is attached to this EMail message.
John
+ Age=GVHD$Age,Drug=GVHD$Drug,Died=GVHD$Died,
+ AgeGrp=cut(GVHD$Age,breaks=c(0,15,25,45)))
MTX MXT+CSP 
     32      32
Call:
coxph(formula = Surv(Time30, Died) ~ Drug, data = GVHDdata)

  n= 64 
                 coef exp(coef) se(coef)     z     p
Drug[T.MXT+CSP] -1.15     0.316    0.518 -2.23 0.026

                exp(coef) exp(-coef) lower .95 upper .95
Drug[T.MXT+CSP]     0.316       3.16     0.115     0.871

Rsquare= 0.086   (max possible= 0.915 )
Likelihood ratio test= 5.75  on 1 df,   p=0.0165
Wald test            = 4.96  on 1 df,   p=0.026
Score (logrank) test = 5.52  on 1 df,   p=0.0188
John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information.  Any unauthorized use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
#
I did not see an attached figure to compare against, perhaps it was removed by the server.  I suspect that:
plot(survfit(fit0,newdata=GVHDdata)
will produce the plot you're looking for. It will generate survival curves for the data in GVHDdata using the estimates from the fit0 coxph model. At least, that's what I gather from the documentation..

Cheers,
On 10/05/09 5:43 PM, "John Sorkin" <jsorkin at grecc.umaryland.edu> wrote:
R 2.8.1
Windows XP

I am trying to plot the results of a coxph using plot(survfit()). The plot should, I believe, show two lines one for survival in each of two treatment (Drug) groups, however my plot shows only one line. What am I doing wrong?

My code is reproduced below, my figure is attached to this EMail message.
John
+ Age=GVHD$Age,Drug=GVHD$Drug,Died=GVHD$Died,
+ AgeGrp=cut(GVHD$Age,breaks=c(0,15,25,45)))
MTX MXT+CSP
     32      32
Call:
coxph(formula = Surv(Time30, Died) ~ Drug, data = GVHDdata)

  n= 64
                 coef exp(coef) se(coef)     z     p
Drug[T.MXT+CSP] -1.15     0.316    0.518 -2.23 0.026

                exp(coef) exp(-coef) lower .95 upper .95
Drug[T.MXT+CSP]     0.316       3.16     0.115     0.871

Rsquare= 0.086   (max possible= 0.915 )
Likelihood ratio test= 5.75  on 1 df,   p=0.0165
Wald test            = 4.96  on 1 df,   p=0.026
Score (logrank) test = 5.52  on 1 df,   p=0.0188
John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}
#
On Sun, 10 May 2009, John Sorkin wrote:

            
Expecting two lines.  To get survival curves from a Cox model you need to specify the covariate values.  If you don't, you get the baseline survival (ie, at the mean covariate values).

Look at the example on ?survfit.coxph
   fit <- coxph(Surv(futime, fustat) ~ age, data = ovarian)
   plot(survfit(fit, newdata=data.frame(age=60)),
      xscale=365.25, xlab = "Years", ylab="Survival")

This plots the fitted curve for age 60. If you wanted multiple ages you can specify them, eg,
   plot(survfit(fit, newdata=data.frame(age=c(40,50,60))),
      xscale=365.25, xlab = "Years", ylab="Survival") 
gives three curves.

       -thomas