build_chairs: Calculate the odds ratio (OR) and the SE(log(OR))

View source: R/build_chairs.R

build_chairsR Documentation

Calculate the odds ratio (OR) and the SE(log(OR))

Description

build_chairs() calculates the odds ratio [OR] and standard error of the log(odds ratio) or SE(log(OR)) for each factor.

Usage

build_chairs(timber, log_base = exp(1))

Arguments

timber

a tibble of timber, with a table built by build_table.

log_base

numeric: the logarithm base used in the calculation of the SE(log(OR)) from CIs.

Details

The odds ratio and the standard error of the log(odds ratio) can be calculated using a complete contingency table, or using the odds ratio and the confidence intervals (CIs).

Contingency Table

The formula to calculate the odds ratio from a contingency table is:

OR = (A/B) / (C/D)

The formula to calculate the standard error of the log(odds ratio) from a contingency table is:

SE(log(OR)) = sqrt((1/A) + (1/B) + (1/C) + (1/D))

Odds Ratio and CIs

The formula to calculate the standard error of the log(odds ratio) from the CIs is:

SE(log(OR)) = (log(oddsup) - log(oddslo)) / (2 * Z)

where Z is the Z value corresponding to 1/2 alpha, and alpha = 1 - confidence level.

Note, the the choice of logarithm base for this calculation may be specified by the user as log_base (default = e or Euler's number).

Value

A tibble of timber with additional columns: odds_ratio and se_log_or.


iAM-AMR/sawmill documentation built on June 30, 2024, 2:25 a.m.