Skip to content

Instantly share code, notes, and snippets.

@pepijndevos
Created July 19, 2021 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepijndevos/0896abda4ba6eeb2dfd62736545dc6bc to your computer and use it in GitHub Desktop.
Save pepijndevos/0896abda4ba6eeb2dfd62736545dc6bc to your computer and use it in GitHub Desktop.
ARR: 1.06%
ARR: -7.30%
ARR: 1.83%
ARR: 1.11%
ARR: 3.19%
ARR: -2.74%
ARR: -3.50%
RRR: -6.26%
RRR: 35.19%
RRR: -16.34%
RRR: -12.66%
RRR: -60.36%
RRR: 37.28%
RRR: 30.77%
groups = [
[217, 61, 0.77],
[248, 84, 0.82],
[356, 54, 0.85],
[237, 26, 0.89],
[227, 14, 0.91],
[143, 12, 0.95],
[42, 6, 0.91],
]
# https://www.easycalculation.com/formulas/absolute-risk-reduction-formula.html
for cv, cu, p in groups:
cer = cv/(cv+cu)
eer = p
arr = cer - eer
print(f"ARR: {arr*100:.2f}%")
# https://www.easycalculation.com/formulas/relative-risk-reduction-formula.html
for ee, ce, p in groups:
es = p
eer = ee/es
cs = 1-p
cer = ce/cs
rrr = (cer-eer)/cer
print(f"RRR: {rrr*100:.2f}%")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment