Hi Statlist!
Could anyone help me with some code to calculate the Hosmer-Lemeshow test after meqrlogit?
Thanks a lot!
Andrea
Could anyone help me with some code to calculate the Hosmer-Lemeshow test after meqrlogit?
Thanks a lot!
Andrea
// FIRST RUN THE meqrlogit MODEL // PICK ONE OF THE TWO VERSIONS OF phat BELOW: // EITHER GET MODEL PREDICTED RISK BASED ON FIXED EFFECTS predict phat, xb replace phat = invlogit(phat) // OR, IF YOU PREFER TO INCLUDE RANDOM EFFECTS predict phat, mu // GET DECILES OF PREDICTED RISK xtile decile = phat, nq(10) // CALCULATE PREDICTED AND OBSERVED OUTCOMES // IN EACH DECILE, AND SHOW TABLE collapse (sum) phat outcome, by(decile) list, noobs clean // CALCULATE CHI SQUARE STATISTIC gen chi2 = (outcome-phat)^2/phat summ chi2, meanonly display "H-L Chi square = `r(sum)'" display "p = `=chi2tail(8, `r(sum)'')"
Comment