Learn R Programming

plotor (version 0.7.0)

check_or: Check OR

Description

Performs a series of tests to ensure that assumptions for logistic regression are met, with optional detailed feedback if any tests fail.

Usage

check_or(glm_model_results, confint_fast_estimate = FALSE, details = TRUE)

Value

Logical, TRUE if all assumption tests pass, FALSE if one or more tests fail

Arguments

glm_model_results

Results from a binomial Generalised Linear Model (GLM), as produced by stats::glm().

confint_fast_estimate

Boolean (default = FALSE) Use a faster estimate of the confidence interval? Note: this assumes normally distributed data, which may not be suitable for your data.

details

Boolean (default = TRUE) Show detailed feedback for any failed tests?

Examples

Run this code
# Load the Titanic dataset
df <- datasets::Titanic |>
  dplyr::as_tibble() |>
  # convert aggregated counts to individual observations
  dplyr::filter(n > 0) |>
  tidyr::uncount(weights = n) |>
  # convert character variables to factors
  dplyr::mutate(dplyr::across(dplyr::where(is.character), as.factor))

# Perform logistic regression using `glm`
lr <- stats::glm(
  data = df,
  family = binomial,
  formula = Survived ~ Class + Sex + Age
)

# Check the model for logistic regression assumption violations
check_or(lr)

Run the code above in your browser using DataLab