ChiangKevin
2012-Mar-29 10:03 UTC
[R] How to calculate the Deviance for test data based on Cox model
Dear List, If I got a Cox model based on training set, then how should I calculate the Cox log partial likelihood for the test data? Actually I am trying to calculate the deviance on test dataset to evaluate the performance of prediction model, the equation is as follows: D = -2{L(test)[beta_train] - L(test)[0]}. It means using the beta coefficients got from training set to calculate the likelihood of test data. I know I can got log likelihood for training model, but how to get it for test data? Any package or function can do that? Thanks. [[alternative HTML version deleted]]
David Winsemius
2012-Mar-29 13:42 UTC
[R] How to calculate the Deviance for test data based on Cox model
On Mar 29, 2012, at 6:03 AM, ChiangKevin wrote:> > > Dear List, > > If I got a Cox model based on training set, then how should I > calculate the Cox log partial likelihood for the test data? > Actually I am trying to calculate the deviance on test dataset to > evaluate the performance of prediction model, the equation is as > follows: D = -2{L(test)[beta_train] - L(test)[0]}. It means using > the beta coefficients got from training set to calculate the > likelihood of test data. I know I can got log likelihood for > training model, but how to get it for test data?Well, that is an equation that has some aspects familiar to many of us, but it is one that does not apply to the statistical problem for which you propose to use it. It applies to "nested" model comparisons, nested both in the sense that the data is the same and the terms are shared.> Any package or function can do that? Thanks. > [[alternative HTML version deleted]]I think you need to seek statistical consultation. -- David Winsemius, MD West Hartford, CT
Thomas Lumley
2012-Mar-29 19:35 UTC
[R] How to calculate the Deviance for test data based on Cox model
On Thu, Mar 29, 2012 at 11:03 PM, ChiangKevin <kevinchiang865 at hotmail.com> wrote:> > > Dear List, > > If I got a Cox model based on training set, then how should I calculate the Cox log partial likelihood for the test data? > Actually I am trying to calculate the deviance on test dataset to evaluate the performance of prediction model, the equation is as follows: D = -2{L(test)[beta_train] - L(test)[0]}. It means using the beta coefficients got from training set to calculate the likelihood of test data. I know I can got log likelihood for training model, but how to get it for test data?One way to do it is to get the linear predictors for the test set (eg with predict.coxph) and use them as an offset coxph(Surv(time,status)~offset(lp), data=testdata) The loglikelihood reported will be the log partial likelihood evaluated at the test data and the fitted parameter values -- Thomas Lumley Professor of Biostatistics University of Auckland