Learn R Programming

ResourceSelection (version 0.1-3)

hoslem.test: Hosmer-Lemeshow Goodness of Fit (GOF) Test

Description

Hosmer-Lemeshow Goodness of Fit (GOF) Test.

Usage

hoslem.test(x, y, g = 10)

Arguments

x
a numeric vector of observations, binary (0/1).
y
expected values.
g
number of bins to use to calculate quantiles.

Value

  • A list with class "htest" containing the following components:
  • statisticthe value of the chi-squared test statistic, (sum((observed - expected)^2 / expected)).
  • parameterthe degrees of freedom of the approximate chi-squared distribution of the test statistic (g - 2).
  • p.valuethe p-value for the test.
  • methoda character string indicating the type of test performed.
  • data.namea character string giving the name(s) of the data.
  • observedthe observed frequencies in a g-by-2 contingency table.
  • expectedthe expected frequencies in a g-by-2 contingency table.

Details

The Hosmer-Lemeshow test is a statistical test for goodness of fit for logistic regression models.

References

Hosmer D W, Lemeshow S 2000. Applied Logistic Regression. New York, USA: John Wiley and Sons.

Examples

Run this code
set.seed(123)
n <- 500
x <- rnorm(n)
y <- rbinom(n, 1, plogis(0.1 + 0.5*x))
m <- glm(y ~ x, family=binomial)
hoslem.test(m$y, fitted(m))

Run the code above in your browser using DataLab