[R] Variable centring within "predict.coxph"
ericjberger at gmail.com
Fri Mar 2 19:19:28 CET 2018
I will state up front that I have no experience or knowledge of the Cox
model or the survival package.
Out of curiosity I loaded the package and did ?coxph and found the
following comment in the documentation:
"The routine internally scales and centers data to avoid overflow in the
argument to the exponential function. These actions do not change the
result, but lead to more numerical stability."
This would seem to imply that for "good" cases, i.e. those which are
numerically stable, the two approaches (centered or not-centered) should
give the same results. Maybe you can find a test data set that is a "good"
case and compare the Stata and R results for that data to gain confidence
that you are calling the package correctly.
On Fri, Mar 2, 2018 at 3:38 PM, Bonnett, Laura <L.J.Bonnett at liverpool.ac.uk>
> 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
> 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):
> test1 <- list(time=c(4,3,1,1,2,2,3),
> mod1 <- coxph(Surv(time, status) ~ x + sex, test1)
> [This can of course be alternatively obtained from mod1$linear.predictor]
> Many thanks for your assistance.
> Kind regards,
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help