Learn R Programming

CLRtools (version 0.1.0)

stukels_test: Stukel’s Test for Logistic Regression Model Fit

Description

This function performs Stukel’s test to assess the goodness-of-fit of a logistic regression model, as adapted from Hosmer et al. (2013) by using the likelihood ratio test .

Usage

stukels_test(model)

Value

A list with the following components:

G

Likelihood ratio test statistic for added z1 and z2.

p_value

P-value for the likelihood ratio test.

model_summary

Summary of the logistic regression model including z1 and z2.

Arguments

model

A fitted logistic regression model of class glm.

References

Hosmer, D. W., Lemeshow, S., & Sturdivant, R. X. (2013). Applied Logistic Regression (3rd ed.). John Wiley & Sons, Inc.

Examples

Run this code
# Example from Hosmer et al., 2013
# Applied Logistic Regression (3rd ed.), Chapter 5, Section 5.2.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
)

# Apply the Stukels test for goodness-of-fit
stukels_test(model.int)

Run the code above in your browser using DataLab