[R] Variable centring within "predict.coxph"

Bonnett, Laura L.J.Bonnett at liverpool.ac.uk
Fri Mar 2 14:38:43 CET 2018


Dear R-help,

I am using R-3.3.2 on Windows 10.  I teach on a course which has 4 computer practical sessions related to the development and validation of clinical prediction models.  These are currently written for Stata and I am in the process of writing them for use in R too (as I far prefer R to Stata!)

I notice that predictions made from a Cox model in Stata are based on un-centred variables, while they are based on centred variables in R.  I am aware that variable centring is the preferred approach to ensure sensible predictions from models and thus usually I am pleased that variable centring is automatically applied within coxph in R.  However, for the sake of producing identical results across the software packages, is there a way to produce predictions from a Cox model in R without variable centring?

I am using the 'survival' package as follows (for example):
library(survival)
test1 <- list(time=c(4,3,1,1,2,2,3),
              status=c(1,1,1,0,1,1,0),
              x=c(0,2,1,1,1,0,0),
              sex=c(0,0,0,0,1,1,1))
mod1 <- coxph(Surv(time, status) ~ x + sex, test1)
predict(mod1,type="lp")

[This can of course be alternatively obtained from mod1$linear.predictor]

Many thanks for your assistance.

Kind regards,
Laura


	[[alternative HTML version deleted]]



More information about the R-help mailing list