Giuseppe.Palermo@bo.infn.it
2005-Jun-09 08:37 UTC
[R] Prediction in Cox Proportional-Hazard Regression
He, I used the "coxph" function, with four covariates. Let's say something like that> model.1 <- coxph(Surv(Time,Event)~X1+X2+X3+X4,data=DATA)So I obtain the 4 coefficients B1,B2,B3,B4 such that h(t) = h0(t) exp(B1*X1+ B2*X2 + B3*X3 + B4*X4). When I use the function on the same data> predict.coxph(model.1,type="lp")how it works in making the prediction? I mean which is the formula, given the data-point P1=[X1(1),X2(1),X3(1),X4(1)], that the function "predict.coxph" use to make the prediction of P1. I really hope that someone will reply to my question. Best regards to all Giuseppe
Prof Brian Ripley
2005-Jun-09 09:13 UTC
[R] Prediction in Cox Proportional-Hazard Regression
On Thu, 9 Jun 2005 Giuseppe.Palermo at bo.infn.it wrote:> He, > I used the "coxph" function, with four covariates. > > Let's say something like that > >> model.1 <- coxph(Surv(Time,Event)~X1+X2+X3+X4,data=DATA) > > So I obtain the 4 coefficients B1,B2,B3,B4 such that > > h(t) = h0(t) exp(B1*X1+ B2*X2 + B3*X3 + B4*X4). > > When I use the function on the same data > >> predict.coxph(model.1,type="lp")How does that work? predict.coxph is not an exported function!> how it works in making the prediction? > I mean which is the formula, given the data-point P1=[X1(1),X2(1),X3(1),X4(1)], > that the function "predict.coxph" use to make the prediction of P1.>From the code (getAnywhere("predict.coxph"))if (type == "lp" || type == "risk") { if (missing(newdata)) { pred <- object$linear.predictors names(pred) <- names(object$residuals) } else pred <- x %*% coef + offset ... so that is the formula it uses. As you did not supply 'newdata', it quotes the 'linear.predictors' component of the fit: see ?coxph.object. Effectively it centred the explanatory variables on their means and then applied the linear regression formula to give the linear predictor. It is the centring that may be non-obvious: effectively h_0(t), the baseline hazard, is taken at the average of the subjects. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595