# Example from Hosmer et al., 2013
# Applied Logistic Regression (3rd ed.), Chapter 5, Table 5.2
# Recode 'raterisk' into a binary variable 'raterisk_cat'
glow500 <- dplyr::mutate(
glow500,
raterisk_cat = dplyr::case_when(
raterisk %in% c("Less", "Same") ~ "C1",
raterisk == "Greater" ~ "C2"
)
)
# Fit a multiple logistic regression model with interactions
model.int <- glm(
fracture ~ age + height + priorfrac + momfrac + armassist +
raterisk_cat + age * priorfrac + momfrac * armassist,
family = binomial,
data = glow500
)
# Perform Hosmer-Lemeshow test with default 10 groups
DRtest(model.int)
Run the code above in your browser using DataLab