Model a yes/no outcome and report it the way clinical papers do.
Your browser does not support embedded video. Download the video (MP4) .
:::
The R code
Everything in the video, ready to copy:
# 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 )
Download this R script · ▶ Practice in the playground
When to use it. Use it for a binary outcome; exponentiate the coefficients to get odds ratios, and judge the model with the ROC curve and AUC.
Go deeper: the Clinical R Toolkit · read logistic regression, OR & ROC .
Next: Kaplan-Meier Survival Curves →