Learn R Programming

CLRtools (version 0.1.0)

diagnosticplots_class: Diagnostic Plots for Model Discrimination

Description

Generates four diagnostic plots to evaluate the discriminatory ability of a logistic regression model. These plots follow the style of those presented by Hosmer et al. (2013) and are helpful for visually assessing model performance.

Usage

diagnosticplots_class(model)

Value

This function displays a 2x2 grid of diagnostic plots.

Arguments

model

A fitted logistic regression model object of class glm, with a binary outcome.

Details

This function creates the following diagnostic plots:

  1. A jitter plot showing the distribution of the estimated probabilities against the observed outcome.

  2. An ROC curve displaying sensitivity versus 1-specificity.

  3. A histogram of estimated probabilities for observations with outcome = 0.

  4. A histogram of estimated probabilities for observations with outcome = 1.

References

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

See Also

cutpoints

Examples

Run this code
# Example from Hosmer et al., 2013
# Applied Logistic Regression (3rd ed.), Chapter 5, Section 5.2.4

# 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
)

# Generate classification diagnostic plots
diagnosticplots_class(model.int)

Run the code above in your browser using DataLab