# 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