Learn R Programming

blorr (version 0.3.2)

blr_test_hosmer_lemeshow: Hosmer-Lemeshow test

Description

Hosmer-Lemeshow goodness of fit test.

Usage

blr_test_hosmer_lemeshow(model, data = NULL)

Arguments

model

An object of class glm. Only binary logistic regression models (binomial family with logit link) are supported. Weighted models (any prior weight other than 1) and grouped binomial models (cbind(successes, failures) or proportions) are not supported; the model must be fitted with model = TRUE, y = TRUE.

data

a tibble or data.frame.

Details

The degrees of freedom are g - 2, where g is the number of partition groups actually used. The table prints exactly those groups, so a model with fewer than 10 groups no longer prints empty rows. With fewer than three groups the test is not available and the statistic, degrees of freedom and p-value are NA: with few groups the test is degenerate, for example a model with a single binary predictor gives only two groups and a p-value close to one, which should not be read as evidence of good fit. Weighted models are rejected before the test by the shared model guard.

References

Hosmer, D.W., Jr., & Lemeshow, S. (2000), Applied logistic regression(2nd ed.). New York: John Wiley & Sons.

See Also

Other model validation techniques: blr_confusion_matrix(), blr_decile_capture_rate(), blr_decile_lift_chart(), blr_gains_table(), blr_gini_index(), blr_ks_chart(), blr_lorenz_curve(), blr_roc_curve()

Examples

Run this code
model <- glm(honcomp ~ female + read + science, data = hsb2,
             family = binomial(link = 'logit'))

blr_test_hosmer_lemeshow(model)

Run the code above in your browser using DataLab