Hi Laura,
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.
HTH,
Eric
On Fri, Mar 2, 2018 at 3:38 PM, Bonnett, Laura <L.J.Bonnett at
liverpool.ac.uk>
wrote:
> 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]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
[[alternative HTML version deleted]]