1
$\begingroup$

I am trying to get Schoenfeld residuals for testing data, using the model parameters obtained from training data. However in r, predict.coxph gives only the linear predictors and their exponentials. Could anyone give me some suggestion?

$\endgroup$

closed as off-topic by Michael M, kjetil b halvorsen, Michael Chernick, jbowman, Peter Flom Jan 13 '18 at 14:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Michael M, kjetil b halvorsen, Michael Chernick, jbowman, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ All your suggestions are about getting Schoenfeld residuals for the current dataset, not the testing data. To do so for the testing data, you get the parameter, say, beta, and doresidual(coxph(..., data = testing, init = beta, control = coxph.control(iter.max)), type = "schoenfeld") $\endgroup$ – Amber Xue Jan 18 '18 at 19:51
2
$\begingroup$

Use cox.zph from the survival package in the format of:

viol <- cox.zph(cox.model)

This will give you a table of hazard assumption test results (if significant, the coefficient is time-varying). You can plot the cox.zph to plot the Schoenfeld residuals, which looks something like:

plot(viol.cox)

enter image description here

Per coefficient.

$\endgroup$
  • $\begingroup$ thanks but not quite what I'm asking $\endgroup$ – Amber Xue Feb 13 '17 at 16:30
1
$\begingroup$

In my opinion, Yuval nails it quite well.

If you want to get the exact (scaled) Schoenfeld residuals for all covariates, access them from the viol .zph object like that: viol$y and viol$x gives you the corresponding time steps that you would need to rebuild Yuval's plot from scratch.

$\endgroup$
  • $\begingroup$ Not what I was asking. $\endgroup$ – Amber Xue Jan 18 '18 at 19:53
1
$\begingroup$

You can also get them out just using the residual function

residual( <coxmodel>  ,  type = "scaledsch")
$\endgroup$
  • $\begingroup$ Not what I was asking. $\endgroup$ – Amber Xue Jan 18 '18 at 19:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.