Learn R Programming

sjstats (version 0.15.0)

hoslem_gof: Hosmer-Lemeshow Goodness-of-fit-test

Description

This method performs a Hosmer-Lemeshow goodness-of-fit-test for generalized linear (mixed) models for binary data.

Usage

hoslem_gof(x, g = 10)

Arguments

x

Fitted glm or glmer model.

g

Number of bins to divide the data. Default is 10.

Value

An object of class hoslem_test with following values:

  • chisq the Hosmer-Lemeshow chi-squared statistic

  • df degrees of freedom

  • p.value the p-value for the goodness-of-fit test

References

Hosmer, D. W., & Lemeshow, S. (2000). Applied Logistic Regression. Hoboken, NJ, USA: John Wiley & Sons, Inc. 10.1002/0471722146

See Also

r2

Examples

Run this code
# NOT RUN {
data(efc)
# goodness-of-fit test for logistic regression
efc$services <- ifelse(efc$tot_sc_e > 0, 1, 0)
fit <- glm(services ~ neg_c_7 + c161sex + e42dep, data = efc,
           family = binomial(link = "logit"))
hoslem_gof(fit)

# }

Run the code above in your browser using DataLab