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))
}

--
View this message in context: 
http://r.789695.n4.nabble.com/Hosmer-Lemeshow-test-for-Cox-model-tp4635482.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.

Reply via email to