Skip to contents

Risk ratio (relative risk) for a 2x2 table

Usage

risk_ratio(a, b, c, d, confidence = 0.95)

Arguments

a, b, c, d

Cell counts of the 2x2 table: a = exposed with outcome, b = exposed without, c = unexposed with outcome, d = unexposed without.

confidence

Confidence level. Default 0.95.

Value

A morie_effect_size.

Examples

# Relative risk: risk in exposed / risk in unexposed.
res <- risk_ratio(20, 80, 10, 90)
res$estimate                 # (20/100) / (10/100) = 2
#> [1] 2
c(lower = res$ci_lower, upper = res$ci_upper)
#>     lower     upper 
#> 0.9865632 4.0544792 

# RR and OR agree for rare outcomes, diverge for common ones:
c(RR = risk_ratio(20, 80, 10, 90)$estimate,
  OR = odds_ratio(20, 80, 10, 90)$estimate)
#>   RR   OR 
#> 2.00 2.25 

risk_ratio(20, 80, 10, 90, confidence = 0.90)$ci_upper
#> [1] 3.619036