odds_ratios: Calculate odds ratios from contingency table

View source: R/odds_ratios.R

odds_ratiosR Documentation

Calculate odds ratios from contingency table

Description

Calculates either local, cumulative, or global odds ratios for a given contingency table (best made with 'xtabs'). Follows the general form equation given in Agresti, 2010 pg 23. Can also support a table of probabilities rather than counts so long as 'n' is provided.

Usage

odds_ratios(
  table,
  type = "cumulative",
  n = NA,
  use_confint = TRUE,
  bonf = FALSE,
  reverse = FALSE
)

Arguments

table

Contingency table, recommended to use 'xtabs'

type

String of which logit to return, either cumulative (default), local, or global

n

If using probabilities instead of counts, the total number of observations

use_confint

Logical, default TRUE, whether 95 should be calculated and reported in a table

bonf

Logical, default FALSE, whether to use Bonferroni correction on standard errors

reverse

Logical, default FALSE, whether to reverse the table to be descending rather than ascending.

Details

Note that the interpretation of the resulting 'odds_ratio' index changes depending on the ordering of the factors. 'xtabs' will use increasing order (highest X on the right) while Agresti's textbook uses decreasing order (highest X on the left). The signs of the estimates are the same regardless of the order, though. If you would like them to be reversed, use the 'reverse' argument.

95 and Bonferroni corrections to the standard errors are also supported.

Value

data.frame with odds ratios, standard errors, and confidence intervals


tsostarics/sostools documentation built on Nov. 22, 2022, 7:26 p.m.