hltest | R Documentation |
Computes the Hosmer-Lemeshow goodness-of-fit test for a generalized linear model fitted to binary responses.
hltest(model, verbose = TRUE, ...)
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, |
... |
further arguments passed to or from other methods. |
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, |
Hosmer D.W., Lemeshow S. (2000) Applied Logistic Regression. 2nd ed. John Wiley & Sons, New York.
###### 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.