Calculates the Hosmer and Lemeshow goodness of fit test.
hoslem_test
the Hosmer and Lemeshow goodness of fit test.
hoslem_test(y, yhat, g = 10)
y
: a vector of observations (0/1).yhat
: a vector of predicted probabilities.g
: Number of groups tested. Default is 10. Can not be < 3.The Chi-squared test statistic, the p-value, the observed and expected frequencies.
fit <- glm(Mortality ~ Dementia + factor(Mobility) + ASA + Gender + Age, data=hipstudy, family=binomial) pred <- predict(fit, type = "response") hoslem_test(fit$y, pred)
Kleinman K and Horton NJ. (2014). SAS and R: Data Management, Statistical Analysis, and Graphics. 2nd Edition. Chapman & Hall/CRC.
pool_performance
Martijn Heymans, 2021