Skip to content
Prev 316655 / 398506 Next

obtainl survival curves for single strata

Stephen,
    I can almost but not quite get my arms around what you are asking.  A bit more detail 
would help.  Like
      cph.approve = what kind of object, generated by function __

But, let me make a guess:
    cph is the result of coxph, and the model has both covariates and a strata
    You want predictioned survival curves, more than 1, of the type "covariates = a, b,c, 
strata=1"  "covariates = d,e, f, strata=2", ... for arbitrary covariates and strata.

Now, the predicted survival curves for different strata are different lengths.
The survfit.coxph routine gets around this by being verbose: it expects you to give it 
covariate sets, and returns
all of the strata for each covariate. This allows it to give a compact result.   You can 
always do:
    newpred <- survfit(cox-model-fit, newdata=something)
    newpred[5,17] #  survival curve for the 5th strata, covariates from the 17th row of 
newdata

But, you want to put the results into a matrix, for some pre-specifed set of time points.  
Take it one step further.
     mytimepoints <- seq(0, 5*365, by=30)  # every 30 days
     z <- summary(newpred[5,17], time=mytimepoints, extend=TRUE)$surv

The summary.survfit function's "time" argument was originally written for people who only 
wanted to print certain time points, but it works as well for those who only want to 
extract certain ones.  It correctly handles the fact that the curve is a step function.

Terry Therneau
On 02/01/2013 05:00 AM, r-help-request at r-project.org wrote: