plot_or | R Documentation |
Produces an Odds Ratio plot to visualise the results of a logistic regression analysis.
plot_or(glm_model_results, conf_level = 0.95, confint_fast_estimate = FALSE)
glm_model_results |
Results from a binomial Generalised Linear Model (GLM), as produced by |
conf_level |
Numeric value between 0.001 and 0.999 (default = 0.95) specifying the confidence level for the confidence interval. |
confint_fast_estimate |
Boolean (default = |
The function returns an object of class gg
and ggplot
, which can be
customised and extended using various ggplot2
functions.
See vignette('using_plotor', package = 'plotor') for more details on usage.
More details and examples can be found on the website: https://craig-parylo.github.io/plotor/index.html
# Load required libraries
library(plotor)
library(datasets)
library(dplyr)
library(ggplot2)
library(stats)
library(forcats)
library(tidyr)
# Load the Titanic dataset
df <- datasets::Titanic |>
as_tibble() |>
# convert aggregated counts to individual observations
filter(n > 0) |>
uncount(weights = n) |>
# convert character variables to factors
mutate(across(where(is.character), as.factor))
# Perform logistic regression using `glm`
lr <- glm(
data = df,
family = 'binomial',
formula = Survived ~ Class + Sex + Age
)
# Produce the Odds Ratio plot
plot_or(lr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.