This method performs a Hosmer-Lemeshow goodness-of-fit-test for generalized linear (mixed) models for binary data.
hoslem_gof(x, g = 10)
x | Fitted |
---|---|
g | Number of bins to divide the data. Default is 10. |
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
A well-fitting model shows no significant difference between the model and the observed data, i.e. the reported p-value should be greater than 0.05.
Hosmer, D. W., & Lemeshow, S. (2000). Applied Logistic Regression. Hoboken, NJ, USA: John Wiley & Sons, Inc. doi: 10.1002/0471722146
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)#> $chisq #> [1] 6.811464 #> #> $df #> [1] 8 #> #> $p.value #> [1] 0.5571044 #> #> attr(,"class") #> [1] "hoslem_test" "list"