hoslem_test: Calculates the Hosmer and Lemeshow goodness of fit test.

View source: R/hoslem_test.R

hoslem_testR Documentation

Calculates the Hosmer and Lemeshow goodness of fit test.

Description

hoslem_test the Hosmer and Lemeshow goodness of fit test.

Usage

hoslem_test(y, yhat, g = 10)

Arguments

y

a vector of observations (0/1).

yhat

a vector of predicted probabilities.

g

Number of groups tested. Default is 10. Can not be < 3.

Value

The Chi-squared test statistic, the p-value, the observed and expected frequencies.

Author(s)

Martijn Heymans, 2021

References

Kleinman K and Horton NJ. (2014). SAS and R: Data Management, Statistical Analysis, and Graphics. 2nd Edition. Chapman & Hall/CRC.

See Also

pool_performance

Examples

  fit <- glm(Mortality ~ Dementia + factor(Mobility) + ASA + 
   Gender + Age, data=hipstudy, family=binomial) 
   pred <- predict(fit, type = "response")
  
  hoslem_test(fit$y, pred)
 

psfmi documentation built on July 9, 2023, 7:02 p.m.