Learn R Programming

CLRtools (version 0.1.0)

rcv_measures: Model Fit Evaluation: R^2-like Measures for Logistic Regression Models with J < n

Description

This function computes several R^2-like measures for logistic regression models, including the squared Pearson correlation coefficient, pseudo R-squared, adjusted R-squared, shrinkage-adjusted R-squared, and log-likelihood-based R-squared. These metrics, adapted from Hosmer et al. (2013), are specifically designed for datasets where the number of covariates (J) is smaller than the number of data points (n), providing a comprehensive assessment of model fit in such contexts.

Usage

rcv_measures(model)

Value

A list containing the following measures:

squared.Pearson.cc

The squared Pearson correlation coefficient.

R_ss

The linear regression-like measure or pseudo R-squared value.

ajusted_R

The adjusted R-squared value, adjusted for the number of covariates and sample size.

adjust_shrink_R

The shrinkage-adjusted R-squared value, which accounts for potential shrinkage in model estimates.

R_LS

The log-likelihood-based R-squared value.

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.

See Also

cov.patterns, residuals_logistic

Examples

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

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

# Compute R-squared-like model fit statistics assuming J < n
rcv_measures(model.int)

Run the code above in your browser using DataLab