# What is the “$R^2$” value given in the summary of a coxph model in R

What is the $R^2$ value given in the summary of a coxph model in R? For example,

Rsquare= 0.186   (max possible= 0.991 )


I foolishly included it a manuscript as an $R^2$ value and the reviewer jumped on it saying he wasn't aware of an analogue of the $R^2$ statistic from the classic linear regression being developed for the Cox model and if there was one please provide a reference. Any help would be great!

• In most situations where the concept of $R^2$ is extended beyond classical linear regression, it is the squared correlation between the observed values and those predicted under the model. Could that possibly be applicable here? – Macro Jun 19 '12 at 12:54
• No it is not related to that. – Frank Harrell Jul 17 '13 at 22:39

Using getS3method("summary","coxph") you can look at how it is calculated.

The relevant code lines are the following:

logtest <- -2 * (cox$loglik - cox$loglik)
rval$rsq <- c(rsq = 1 - exp(-logtest/cox$n), maxrsq = 1 -
exp(2 * cox$loglik/cox$n))


Here cox$loglik is "a vector of length 2 containing the log-likelihood with the initial values and with the final values of the coefficients" (see ?coxph.object) and cox$n is "number of observations used in the fit".

Dividing by $n$ the number of observations in the summary of coxph is wrong, it should be the number of uncensored events; see O'Quigley et al. (2005) Explained randomness in proportional hazards models Statistics in Medicine p. 479-489.

• Incorrect, you divide by the number of observations, no matter how strange that sounds. To the original question, it is strange that a reviewer would not be aware of something that's been around for 20 years for the Cox model. – Frank Harrell Jul 17 '13 at 22:40
• Adding to the exchange between Ronghui Xu and @Frank Harrell, not only does it sound strange'' dividing by the number of observations, it does not work. To see this, consider beta fixed at some value so that, roughly, E(R2)=0.5, and the same covariate distribution, i.e., everything the same, apart from the fact that Study 1 has twice the rate of censoring as Study 2. Although we should be estimating the same population quantity, the R2 estimates in Study 1 will be roughly half those of Study 2, regardless of sample size. Instead of 0.5 we would be getting around 0.25. – user28171 Jul 18 '13 at 7:47
• John it would be worth providing a little R simulation to show that. The null log likelihood also changes, doesn't it? - possibly compensating for the effect you described. Whether generalized $R^2$ us deficient in some ways or not it is highly used and there is some theory to support its strange setup. – Frank Harrell Jul 18 '13 at 18:10
• In answer to Frank's remark, I would agree that this is not straightforward and that Frank's observation concerning the null log-likelihood is correct. I only ever viewed this quantity as an approximation to a consistent estimator of a well-defined population quantity based on information gain. The paper referred to by Ronghui Xu does carry out simulations. These show the impact of censoring, although not absent, to be much weaker when we divide by the number of failures rather than the total number of observations. – user28171 Jul 18 '13 at 19:50
• John would you and Ronghui tell us which measure you currently recommend? I am seeking a fraction of explained randomness that is very independent of the censoring distribution, is a strong analogy of $R^2$ in linear models, and that has a ready counterpart for logistic regression. I finally read your excellent 2005 paper - nice work. – Frank Harrell Jul 20 '13 at 15:38