hltest {glmtoolbox}R Documentation

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. As default, verbose is set to TRUE.

...

further arguments passed to or from other methods.

Value

A matrix with the following four columns:

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., Lemeshow S. (2000) Applied Logistic Regression. 2nd ed. John Wiley & Sons, New York.

Examples


###### Example 1: Patients with burn injuries
burn1000 <- aplore3::burn1000
burn1000 <- within(burn1000, death <- factor(death, levels=c("Dead","Alive")))
fit1 <- glm(death ~ age*inh_inj + tbsa*inh_inj, family=binomial("logit"), data=burn1000)
hltest(fit1)

###### Example 2: Bladder cancer in mice
data(bladder)
fit2 <-  glm(cancer/exposed ~ dose, weights=exposed, family=binomial("cloglog"), data=bladder)
hltest(fit2)

###### Example 3: Liver cancer in mice
data(liver)
fit3 <-  glm(cancer/exposed ~ dose, weights=exposed, family=binomial("probit"), data=liver)
hltest(fit3)


[Package glmtoolbox version 0.1.12 Index]