table_or {plotor}R Documentation

Table OR

Description

Produces a formatted table showing the outputs from the Odds Ratio analysis, including details on covariate characteristics and model results.

Usage

table_or(
  glm_model_results,
  conf_level = 0.95,
  output = "tibble",
  confint_fast_estimate = FALSE
)

Arguments

glm_model_results

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

conf_level

Numeric value between 0.001 and 0.999 (default = 0.95) specifying the confidence level for the confidence interval.

output

String describing of the output type (default = 'tibble'). Options include 'tibble' and 'gt'.

confint_fast_estimate

Boolean (default = FALSE) indicating whether to use a faster estimate of the confidence interval. Note: this assumes normally distributed data, which may not be suitable for your data.

Details

The table includes the following information:

Includes details on the characteristics of the covariates, such as:

Details are calculated showing the:

Also included is a visualisation of the OR plot to provide an at-a-glance view of the model results.

Value

The returned object depends on the output parameter:

Examples

# 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
)

# Produce the Odds Ratio table as a tibble
table_or(lr)

# Produce the Odds Ratio table as a gt object
table_or(lr, output = 'gt')

[Package plotor version 0.7.0 Index]