

Dear list,
Usually we use HosmerLemeshow test to test the goodness of fit for logistic model, but if I use it to test for Cox model, how can I get the observed probability for each group?
Suppose I calculated the 5year predicted probability using Cox model, then I split the dataset into 10 group according to this predicted probability. We should compare the observed probability with predicted probability within each group,but how to calculate this observed probability, should I use KaplanMeier to estimate it? how should I modify the following program,thanks.
hosmerlem = function(y, yhat, g=10) {
cutyhat = cut(yhat,
breaks = quantile(yhat, probs=seq(0,
1, 1/g)), include.lowest=TRUE)
obs = xtabs(cbind(1  y, y) ~ cutyhat)
expect = xtabs(cbind(1  yhat, yhat) ~ cutyhat)
chisq = sum((obs  expect)^2/expect)
P = 1  pchisq(chisq, g  2)
return(list(chisq=chisq,p.value=P))
}


Any method that requires binning is problematic. Instead, take a look at the calibrate function in the rms package. There is a new option for continuous calibration curves for survival models.
Frank
jane.wong wrote
Dear list,
Usually we use HosmerLemeshow test to test the goodness of fit for logistic model, but if I use it to test for Cox model, how can I get the observed probability for each group?
Suppose I calculated the 5year predicted probability using Cox model, then I split the dataset into 10 group according to this predicted probability. We should compare the observed probability with predicted probability within each group,but how to calculate this observed probability, should I use KaplanMeier to estimate it? how should I modify the following program,thanks.
hosmerlem = function(y, yhat, g=10) {
cutyhat = cut(yhat,
breaks = quantile(yhat, probs=seq(0,
1, 1/g)), include.lowest=TRUE)
obs = xtabs(cbind(1  y, y) ~ cutyhat)
expect = xtabs(cbind(1  yhat, yhat) ~ cutyhat)
chisq = sum((obs  expect)^2/expect)
P = 1  pchisq(chisq, g  2)
return(list(chisq=chisq,p.value=P))
}
Frank Harrell
Department of Biostatistics, Vanderbilt University

