Skip to contents

Risk difference for a 2x2 table

Usage

risk_difference(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

# Absolute difference in risk between exposed and unexposed.
res <- risk_difference(20, 80, 10, 90)
res$estimate                 # 0.20 - 0.10 = 0.10
#> [1] 0.1
c(lower = res$ci_lower, upper = res$ci_upper)
#>       lower       upper 
#> 0.002001801 0.197998199 

# RD = 0 means equal risk; sign shows direction.
risk_difference(10, 90, 20, 80)$estimate     # -0.10 (exposed lower)
#> [1] -0.1