log_odds_ratio: Log odds ratio

View source: R/log_odds_ratio.R

log_odds_ratioR Documentation

Log odds ratio

Description

Calculate log odds ratio (i.e., ln of odds ratio), as illustrated in Borenstein et al. (2009, p. 36, ISBN: 978-0-470-05724-7)

Usage

log_odds_ratio(
  data = NULL,
  iv_name = NULL,
  dv_name = NULL,
  contingency_table = NULL,
  ci = 0.95,
  var_include = FALSE,
  invert = FALSE
)

Arguments

data

a data object (a data frame or a data.table)

iv_name

name of the independent variable (grouping variable)

dv_name

name of the dependent variable (binary outcome)

contingency_table

a contingency table, which can be directly entered as an input for calculating the odds ratio

ci

width of the confidence interval. Input can be any value less than 1 and greater than or equal to 0. By default, ci = 0.95. If ci = TRUE, the default value of 0.95 will be used. If ci = FALSE, no confidence interval will be estimated.

var_include

logical. Should the output include variance of the log of odds ratio? (default = FALSE)

invert

logical. Whether the inverse of the odds ratio (i.e., 1 / odds ratio) should be returned.

Examples

## Not run: 
log_odds_ratio(data = mtcars, iv_name = "vs", dv_name = "am")
log_odds_ratio(contingency_table = matrix(c(5, 10, 95, 90), nrow = 2))
log_odds_ratio(contingency_table = matrix(c(5, 10, 95, 90), nrow = 2),
invert = TRUE)
log_odds_ratio(contingency_table = matrix(c(34, 39, 16, 11), nrow = 2))
log_odds_ratio(contingency_table = matrix(c(34, 39, 16, 11), nrow = 2),
var_include = TRUE)

## End(Not run)

kim documentation built on Oct. 9, 2023, 5:08 p.m.