The survfit function, when applied to the results of a Cox model, will give the predicted survival curve for any particular combination of covariates in the model. You cannot get what you are asking for, i.e., distinct levels of X while ignoring Y, from survfit. What you need to do is create a data frame containing values for the curves that you want, e.g., mydata <- data.frame(X=c(1,2,3,4), y=c(8,8,8,8)) cfit <- survfit(mod.phm, newdata=mydata) plot(cfit, lty=1:4) People often choose a 'common' value of y for the plot.
Arguably the better approach is to average over the levels of y. For this, I would recommend that you read chapter 10 of Therneau and Grambsch, Modeling Survival Data. The discussion really does take a whole chapter, and is too long for a help-list synopsis. Terry Therneau ------------------------------------------------------------ begin included message Thanks for your help. I want to draw a plot which shows separate survival curves for each category of X on the same plot(same set of axes). Your code produces a separate curve for each combination of X and Y but I don't want curves for combinations of X and Y since Y has many levels and also the values of Y don't have any significance in my case. Is there a way of doing what i want to do i.e. getting separate survival curves for each level of X using the function survfit() on an object mod.phm which is a coxph object such that: mod.phm<-coxph(formula=Surv(time,Flag_Death)~X+Y, data= datFrame) ______________________________________________ R-help@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.