In the following example, we will apply the Hosmer-Lemeshow test to the PainGLM dataset. We will implement the Hosmer-Lemeshow test via the hoslem.test() function contained within the ResourceSelection package.
To set up the test, supply the observed values, with the fitted (predicted) values as part of the hoslem.test() function:
The hoslem.test output is written to the console:
Hosmer and Lemeshow goodness of fit (GOF) test data: PainGLM$y, fitted(PainGLM) X-squared = 8.4981, df = 8, p-value = 0.3864
From the p-value statistic (0.38) the test shows that there is no problem with the fit.