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 Hosmer-Lemeshow 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 5-year 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 Kaplan-Meier 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 -- View this message in context: http://r.789695.n4.nabble.com/Hosmer-Lemeshow-test-for-Cox-model-tp4635482p4635492.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list 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.