The function computes Hosmer-Lemeshow goodness of fit tests for C and H statistic as well as the le Cessie-van Houwelingen-Copas-Hosmer unweighted sum of squares test for global goodness of fit.

HosmerLemeshowTest(fit, obs, ngr = 10, X, verbose = FALSE)

Arguments

fit

numeric vector with fitted probabilities.

obs

numeric vector with observed values.

ngr

number of groups for C and H statistic.

X

covariate(s) for le Cessie-van Houwelingen-Copas-Hosmer global goodness of fit test.

verbose

logical, print intermediate results.

Details

Hosmer-Lemeshow goodness of fit tests are computed; see Lemeshow and Hosmer (1982).

If X is specified, the le Cessie-van Houwelingen-Copas-Hosmer unweighted sum of squares test for global goodness of fit is additionally determined; see Hosmer et al. (1997).

Value

A list of tests.

References

Lemeshow, S. 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.

Hosmer, D.W., Hosmer, T., le Cessie, S., Lemeshow, S. (1997). A comparison of goodness-of-fit tests for the logistic regression model. Statistics in Medicine, 16, 965-980.

Author

Matthias Kohl <Matthias.Kohl@stamats.de>

See also

Examples

set.seed(111)

x1 <- factor(sample(1:3, 50, replace = TRUE))
x2 <- rnorm(50)
obs <- sample(c(0,1), 50, replace = TRUE)

fit <- glm(obs ~ x1+x2, family = binomial)

HosmerLemeshowTest(fit = fitted(fit), obs = obs, X = cbind(x1, x2))
#> Warning: This function will be moved to the package ModTools. Please update.
#> $C
#> 
#> 	Hosmer-Lemeshow C statistic
#> 
#> data:  fitted(fit) and obs
#> X-squared = 4.8497, df = 8, p-value = 0.7735
#> 
#> 
#> $H
#> 
#> 	Hosmer-Lemeshow H statistic
#> 
#> data:  fitted(fit) and obs
#> X-squared = 4.9719, df = 8, p-value = 0.7606
#> 
#> 
#> $gof
#> 
#> 	le Cessie-van Houwelingen-Copas-Hosmer global goodness of fit test
#> 
#> data:  fitted(fit) and obs
#> z = -0.016918, p-value = 0.9865
#> 
#>