odds_ratio: Odds Ratio from 2x2 Table

View source: R/odds.R

odds_ratioR Documentation

Odds Ratio from 2x2 Table

Description

This function displays odds ratios and their normal confidence intervals. This statistic is calculated as (level 1.1/level 1.2) / (level 2.1/level 2.2), which can be considered the odds of level 1.1 given level1 overall versus level2.1 given level2 overall.

Usage

odds_ratio(n11, n12, n21, n22, a = 0.05)

odds(n11, n12, n21, n22, a = 0.05)

Arguments

n11

sample size for level 1.1

n12

sample size for level 1.2

n21

sample size for level 2.1

n22

sample size for level 2.2

a

significance level

Details

**Note on function and output names:** This effect size is now implemented with the snake_case function name 'odds_ratio()' to follow modern R style guidelines. The original name 'odds()' is still available as a wrapper for backward compatibility, and both functions return the same list. The returned object includes both the original element names (e.g., 'odds', 'olow', 'ohigh', 'se') and newer snake_case aliases (e.g., 'odds_value', 'odds_lower_limit', 'odds_upper_limit', 'standard_error'). New code should prefer 'odds_ratio()' and the snake_case output names, but existing code using the older names will continue to work.

Value

odds

odds ratio statistic (legacy name; see also 'odds_value')

olow

lower-level confidence interval of odds ratio (legacy name; see also 'odds_lower_limit')

ohigh

upper-level confidence interval of odds ratio (legacy name; see also 'odds_upper_limit')

se

standard error (legacy name; see also 'standard_error')

odds_value

odds ratio statistic (snake_case alias of 'odds')

odds_lower_limit

lower-level confidence interval of odds ratio (alias of 'olow')

odds_upper_limit

upper-level confidence interval of odds ratio (alias of 'ohigh')

standard_error

standard error (alias of 'se')

Examples


# A health psychologist was interested in the rates of anxiety in
# first generation and regular college students. They polled campus
# and found the following data:

  # |              | First Generation | Regular |
  # |--------------|------------------|---------|
  # | Low Anxiety  | 10               | 50      |
  # | High Anxiety | 20               | 15      |

# What are the odds for the first generation students to have anxiety?

odds_ratio(n11 = 10, n12 = 50, n21 = 20, n22 = 15, a = .05)

# Backwards-compatible wrapper (deprecated name)
odds(n11 = 10, n12 = 50, n21 = 20, n22 = 15, a = .05)

MOTE documentation built on Dec. 15, 2025, 9:06 a.m.