hoslem_test function

Calculates the Hosmer and Lemeshow goodness of fit test.

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)

Arguments

  • 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.

Returns

The Chi-squared test statistic, the p-value, the observed and expected frequencies.

Examples

fit <- glm(Mortality ~ Dementia + factor(Mobility) + ASA + Gender + Age, data=hipstudy, family=binomial) pred <- predict(fit, type = "response") hoslem_test(fit$y, pred)

References

Kleinman K and Horton NJ. (2014). SAS and R: Data Management, Statistical Analysis, and Graphics. 2nd Edition. Chapman & Hall/CRC.

See Also

pool_performance

Author(s)

Martijn Heymans, 2021

  • Maintainer: Martijn Heymans
  • License: GPL (>= 2)
  • Last published: 2023-06-17