# Hosmer–Lemeshow test

$H = \sum_{g=1}^{G} \frac{(O_g - E_g)^2}{N_g \pi_g (1-\pi_g)} .\,\!$
Here Og, Eg, Ng, and πg denote the observed events, expected events, observations, predicted risk for the gth risk decile group, and G is the number of groups. The test statistic asymptotically follows a $\chi^2$ distribution with G − 2 degrees of freedom. The number of risk groups may be adjusted depending on how many fitted risks are determined by the model. This helps to avoid singular decile groups.