VerifiedEvidence: highv1.0.0

Hosmer-Lemeshow Test

A goodness of fit test assessing how well a logistic regression model's predicted probabilities match observed outcome frequencies across risk groups.

Last reviewedDarrin Baines IP Ltd

Concept Architecture

Concept

Theoretically, the Hosmer-Lemeshow Test is a goodness-of-fit test used to assess the calibration of a binary logistic regression model by comparing observed and predicted event frequencies across groups of observations with similar predicted probabilities. It is founded on chi-square testing and evaluates whether discrepancies between observed and expected outcomes are larger than would be expected through sampling variation. The test exists to identify systematic disagreement between model predictions and observed event rates.

Mathematically, observations are ordered by predicted probability and divided into groups, commonly deciles of risk. Within each group, the observed numbers of events and non-events are compared with their model-based expected numbers, and the resulting discrepancies are combined into a chi-square statistic. Under the null hypothesis of adequate model fit, the statistic is conventionally compared with a chi-square distribution with G ? 2 degrees of freedom, where G is the number of groups.

In practice, the Hosmer-Lemeshow test is implemented after fitting a logistic regression model by calculating individual predicted probabilities, grouping observations by predicted risk and comparing observed with expected event counts within each group. A large p-value indicates insufficient evidence of poor calibration, whereas a small p-value suggests disagreement between predicted and observed outcomes. In health economics, the test is used when validating logistic models for treatment response, hospitalisation, mortality and other binary outcomes used in decision models and risk adjustment.


Purpose

Used to assess the calibration and overall goodness of fit of binary logistic regression models by comparing observed and expected outcome frequencies across groups of predicted risk.


Mathematical Formulae

Primary Formula

H = ??g???? [(O?g ? E?g)� / E?g + (O?g ? E?g)� / E?g]

H ~ ?�G??

where:

  • H = Hosmer-Lemeshow test statistic
  • G = number of risk groups
  • O?g = observed number of events in group g
  • E?g = expected number of events in group g
  • O?g = observed number of non-events in group g
  • E?g = expected number of non-events in group g

Supporting Formulae

E?g = ???g p??

E?g = n?g? ? E?g

O?g = n?g? ? O?g

p?? = 1 / (1 + exp(???))

?? = ??? + ???x?? + ? + ???x??

Related Mathematical Methods

  • Logistic Regression
  • Chi-Square Test
  • Calibration Plot
  • Calibration Intercept
  • Calibration Slope
  • Brier Score
  • Receiver Operating Characteristic Analysis

Example

A logistic regression model predicts 30-day hospital readmission for 1,000 patients. Patients are divided into ten groups according to predicted readmission risk. In one group of 100 patients, 18 readmissions are observed and 15 are expected, while 82 non-readmissions are observed and 85 are expected.

Group contribution = (18 ? 15)� / 15 + (82 ? 85)� / 85

Group contribution = 9 / 15 + 9 / 85 = 0.706

The contributions from all ten groups are summed to obtain the Hosmer-Lemeshow statistic. If H = 7.42 with 8 degrees of freedom, the corresponding p-value is approximately 0.49. There is therefore insufficient evidence to reject the null hypothesis of adequate model fit.


Excel Implementation

FunctionExample FormulaHealth Economics Application
EXP=1/(1+EXP(-B2))Convert the logistic linear predictor into a predicted probability
RANK.EQ=RANK.EQ(C2,$C$2:$C$1001,1)Rank patients by predicted probability before risk grouping
ROUNDUP=ROUNDUP(RANK.EQ(C2,$C$2:$C$1001,1)/(COUNT($C$2:$C$1001)/10),0)Assign observations to approximate deciles of predicted risk
SUMIFS=SUMIFS($D$2:$D$1001,$E$2:$E$1001,G2)Calculate observed events within each risk group
SUMIFS=SUMIFS($C$2:$C$1001,$E$2:$E$1001,G2)Calculate expected events within each risk group
CHISQ.DIST.RT=CHISQ.DIST.RT(H12,8)Calculate the p-value from the Hosmer-Lemeshow statistic

VBA (Optional)

Automate the ranking of predicted probabilities, formation of risk groups, calculation of observed and expected frequencies and production of the Hosmer-Lemeshow test statistic and p-value.


Sources

  • Hosmer DW, Lemeshow S. Goodness of Fit Tests for the Multiple Logistic Regression Model. Communications in Statistics: Theory and Methods. 1980;9(10):1043-1069.
  • Hosmer DW, Lemeshow S, Sturdivant RX. Applied Logistic Regression. 3rd ed. Wiley; 2013.
  • Steyerberg EW. Clinical Prediction Models. 2nd ed. Springer; 2019.
  • Harrell FE Jr. Regression Modeling Strategies. 2nd ed. Springer; 2015.
  • Briggs AH, Claxton K, Sculpher MJ. Decision Modelling for Health Economic Evaluation. Oxford University Press; 2006.

Library

Publications

1
  • Book

    Statistical Analysis of Cost-Effectiveness Data — Willan & Briggs, 1st Edition ed., 2006 (John Wiley & Sons)

    A synthesis of statistical methods for analysing cost-effectiveness data, including net-benefit regression, confidence intervals for the ICER, cost-effectiveness acceptability curves, and covariate adjustment. Part of the Wiley Statistics in Practice series.

Frequently Asked Questions (6)

  • What is the Hosmer-Lemeshow test?

    A goodness of fit test assessing how well a logistic regression model's predicted probabilities match observed outcome frequencies across risk groups.

    Source: Hosmer & Lemeshow 1980

  • What does the Hosmer-Lemeshow test check about a logistic model?

    The Hosmer-Lemeshow test checks how well a logistic regression model is calibrated, comparing the outcomes it predicts against those actually observed. It sorts patients into groups by their predicted risk and, within each group, compares the predicted number of events with the real number, combining the discrepancies into a single statistic. A poor match signals that the model's probabilities do not correspond to reality, even if it discriminates well. Testing predicted against observed frequencies is its purpose. Steyerberg (2009) describes this test.

    Source: Steyerberg 2009

  • How does the Hosmer-Lemeshow test work?

    The Hosmer-Lemeshow test works by ordering individuals by their predicted probability, dividing them into groups, usually tenths, and comparing the number of observed events with the number expected from the predicted probabilities in each group using a chi-square-type statistic. A large statistic, with a small p-value, indicates poor agreement. So the Hosmer-Lemeshow test works by grouping by predicted risk and testing whether observed and expected event counts match across the groups, summarising the discrepancy into a statistic referred to a chi-square distribution, which provides a formal assessment of whether the model's predicted probabilities are calibrated to the observed outcomes.

    Source: Hosmer & Lemeshow 1980

  • How is the Hosmer-Lemeshow test interpreted?

    The Hosmer-Lemeshow test is interpreted such that a non-significant result, a large p-value, indicates no evidence of poor fit, suggesting the predicted probabilities agree with observed frequencies, while a significant result indicates a lack of fit, with predicted and observed diverging. So the Hosmer-Lemeshow test is interpreted as a check on calibration, where failing to reject suggests adequate fit and rejecting signals miscalibration, though a non-significant result does not prove good fit, especially in small samples with limited power, and the test is interpreted alongside other evidence such as calibration plots rather than relied upon alone.

    Source: Hosmer & Lemeshow 1980

  • What are the limitations of the Hosmer-Lemeshow test?

    The limitations of the Hosmer-Lemeshow test include that its result depends on the arbitrary choice of the number of groups, which can change the conclusion; that it has low power in small samples, so may miss miscalibration, and excessive power in very large ones, flagging trivial departures; and that it gives only an overall verdict, not where miscalibration occurs. So the Hosmer-Lemeshow test is used with caution and alongside calibration plots, since its dependence on grouping and sample size limits its reliability, and a graphical assessment shows where and how predicted and observed probabilities diverge, providing information the single test statistic does not.

    Source: Hosmer & Lemeshow 1980

  • How does the Hosmer-Lemeshow test relate to calibration?

    The Hosmer-Lemeshow test relates to calibration as a formal test of it: calibration is the agreement between predicted probabilities and observed outcome frequencies, and the Hosmer-Lemeshow test assesses this agreement across groups defined by predicted risk. So the Hosmer-Lemeshow test is one way of evaluating calibration for a logistic model, complementing graphical methods such as calibration plots, which display the agreement across the range of risk, and together the test and the plot assess whether a model's predicted probabilities can be trusted, an aspect of performance distinct from discrimination.

    Source: Hosmer & Lemeshow 1980

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 16 Dec 2025

Content version: 1.0.0

Canonical Identity

Term code
HE-ES-SA-079

Stable URI · Machine-readable · Resolvable · CC BY 4.0