binary_metrics_glm: Fit metrics for binary logit model

binary_metrics_glmR Documentation

Fit metrics for binary logit model

Description

Calculation of fit metrices for binary variables (Sensitivity, specificity, accuracy) out of binary logit models (glm object)

Usage

binary_metrics_glm(
  logit_model, 
  threshold = 0.5
  )

Arguments

logit_model

glm object with binary logit model

threshold

Threshold for destinction of probability with respect to TRUE or FALSE

Details

The function computes model performance metrices for binary outcomes. A binary logit model (glm) must be stated by the user. The function returns sensitivity, specificity, accurracy, and no-information rate.

Value

list with two entries:

fit_metrics:

list with fit metrics (sens, spec, ...)

observed_expected:

data.frame with observed, expected and hit (1/0)

Author(s)

Thomas Wieland

References

Altman DG, Bland JM (1994) Diagnostic tests. 1: Sensitivity and specificity. British Medical Journal 308, 1552. \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.1136/bmj.308.6943.1552")}.

Boehmke B, Greenwell B (2020) Hands-On Machine Learning with R (1 ed.). Taylor & Francis, New York, NY.

See Also

metrics, binary_metrics

Examples

dep <- c(1,1,0,0,0,0,1,0,1, 1)
x <- c(2,3,1,1,0,1,3,2,1,3)

testmodel <-
  glm(
    dep~x,
    family=binomial()
  )
  
summary(testmodel)

binary_metrics_glm(testmodel)

swash documentation built on Feb. 15, 2026, 5:07 p.m.