Package 'plotor'

Title: Produces an Odds Ratio Plot from a Logistic Regression Model
Description: Produces an Odds Ratio (OR) Plot to visualise the result of a logistic regression analysis. Provide it with a binomial regression model produced by 'glm()' and it will convert the estimates to odds ratios with a 95% confidence interval and plot the results using 'ggplot2'.
Authors: Craig Parylo [aut, cre, cph]
Maintainer: Craig Parylo <[email protected]>
License: MIT + file LICENSE
Version: 0.5.2
Built: 2025-02-09 11:16:40 UTC
Source: https://github.com/craig-parylo/plotor

Help Index


Plot OR

Description

Produces an Odds Ratio plot to visualise the results of a logistic regression analysis.

Usage

plot_or(glm_model_results, conf_level = 0.95)

Arguments

glm_model_results

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

conf_level

Numeric between 0.001 and 0.999 (default = 0.95). The confidence level to use when setting the confidence interval, most commonly will be 0.95 or 0.99 but can be set otherwise.

Value

plotor returns an object of class gg and ggplot

See Also

See vignette('using_plotor', package = 'plotor') for more details on use.

More details and examples are found on the website: https://craig-parylo.github.io/plotor/index.html

Examples

# libraries
library(plotor)
library(datasets)
library(dplyr)
library(ggplot2)
library(stats)
library(forcats)
library(tidyr)

# get some data
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)

Validate the {glm} model

Description

Check whether the glm model object is the product of logistic regression.

Usage

validate_glm_model(glm_model)

Arguments

glm_model

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

Value

boolean (TRUE = logistic regression, FALSE = other model)