Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

hltest

The Hosmer-Lemeshow Goodness-of-Fit Test


Description

Computes the Hosmer-Lemeshow goodness-of-fit test for a generalized linear model fitted to binary responses.

Usage

hltest(model, verbose = TRUE, ...)

Arguments

model

an object of the class glm which is obtained from the fit of a generalized linear model where the distribution for the response variable is assumed to be binomial.

verbose

an (optional) logical switch indicating if should the report of results be printed. By default, verbose is set to be TRUE.

...

further arguments passed to or from other methods.

Value

A list which contains the following objects:

  • hm: A matrix with the values of Group, Size, Observed and Expected, which are required to compute the statistic of the test.

  • statistic: The value of the statistic of the test.

  • df: The number of degrees of freedom, given by the number of groups minus 2.

  • p.value: The p-value of the test computed using the Chi-square distribution.

References

Hosmer, D.W. and Lemeshow, S. (2000) Applied Logistic Regression. 2nd ed. John Wiley & Sons, New York.

Examples

## Example 1
fit1 <-  glm(cancer/exposed ~ dose, weights=exposed, family=binomial("logit"), data=bladder)
hltest(fit1)

## Example 2
fit2 <-  glm(cancer/exposed ~ dose, weights=exposed, family=binomial("logit"), data=liver)
hltest(fit2)

## Example 3
burn1000 <- aplore3::burn1000
mod <- death ~ age + tbsa + inh_inj + age*inh_inj + tbsa*inh_inj
fit3 <- glm(mod, family=binomial("logit"), data=burn1000)
hltest(fit3)

glmtoolbox

Set of Tools to Data Analysis using Generalized Linear Models

v0.1.0
GPL-2 | GPL-3
Authors
Luis Hernando Vanegas [aut, cre], Luz Marina Rondón [aut], Gilberto A. Paula [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.