| HLtest | R Documentation |
The HLtest function computes the classical Hosmer-Lemeshow (1980)
goodness of fit test for a binomial glm object in logistic regression
HLtest(model, g = 10)
## S3 method for class 'HLtest'
print(x, ...)
## S3 method for class 'HLtest'
summary(object, ...)
## S3 method for class 'HLtest'
rootogram(x, ...)
## S3 method for class 'HLtest'
plot(x, ...)
model |
A |
g |
Number of groups used to partition the fitted values for the GOF test. |
x, object |
A |
... |
Other arguments passed down to methods |
The general idea is to assesses whether or not the observed event rates
match expected event rates in subgroups of the model population. The
Hosmer-Lemeshow test specifically identifies subgroups as the deciles of
fitted event values, or other quantiles as determined by the g
argument. Given these subgroups, a simple chisquare test on g-2 df is
used.
In addition to print and summary methods, a plot method
is supplied to visualize the discrepancies between observed and fitted
frequencies.
A class HLtest object with the following components:
table |
A data.frame describing the results of partitioning the data
into |
chisq |
The chisquare statistics |
df |
Degrees of freedom |
p.value |
p value |
groups |
Number of groups |
call |
|
%% ...
Michael Friendly
Hosmer, David W., Lemeshow, Stanley (1980). A goodness-of-fit test for multiple logistic regression model. Communications in Statistics, Series A, 9, 1043-1069.
Hosmer, David W., Lemeshow, Stanley (2000). Applied Logistic Regression, New York: Wiley, ISBN 0-471-61553-6
Lemeshow, S. and Hosmer, D.W. (1982). A review of goodness of fit statistics for use in the development of logistic regression models. American Journal of Epidemiology, 115(1), 92-106.
rootogram, ~~~
Other association tests:
CMHtest(),
GKgamma(),
zero.test()
data(birthwt, package="MASS")
# how to do this without attach?
attach(birthwt)
race = factor(race, labels = c("white", "black", "other"))
ptd = factor(ptl > 0)
ftv = factor(ftv)
levels(ftv)[-(1:2)] = "2+"
bwt <- data.frame(low = factor(low), age, lwt, race,
smoke = (smoke > 0), ptd, ht = (ht > 0), ui = (ui > 0), ftv)
detach(birthwt)
options(contrasts = c("contr.treatment", "contr.poly"))
BWmod <- glm(low ~ ., family=binomial, data=bwt)
(hlt <- HLtest(BWmod))
str(hlt)
summary(hlt)
plot(hlt)
# basic model
BWmod0 <- glm(low ~ age, family=binomial, data=bwt)
(hlt0 <- HLtest(BWmod0))
str(hlt0)
summary(hlt0)
plot(hlt0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.