# ============================================================
# Logistic Regression & Odds Ratios
# Biostatistics in R — Rverse Analytics
# https://rverseanalytics.com/learn-biostatistics/logistic
# ============================================================

# Logistic regression - odds ratios & ROC
library(gtsummary)
library(pROC)
# Fit a logistic model for tumour response
d <- na.omit(trial[, c("response", "age", "grade", "stage")])
fit <- glm(response ~ age + grade + stage, data = d, family = binomial)
# Adjusted odds ratios with 95% CI
tbl_regression(fit, exponentiate = TRUE) |>
bold_p()
# ROC curve and AUC - how well the model discriminates
roc_obj <- roc(d$response, fitted(fit), quiet = TRUE)
auc(roc_obj)
plot(roc_obj, col = "#2f6fed", lwd = 3, legacy.axes = TRUE)
