Source: https://guthlabs.ai/docs/instruments/relative-risk-odds-ratio-calculator/implementation/

instrument implementation / implementation-contract

# Relative Risk / Odds Ratio Calculator implementation

A source-bound implementation contract for Relative Risk / Odds Ratio Calculator; deployment and executable qualification remain separate.

Status: **VERIFIED_WITH_ERRATA**Lifecycle: **implementation-contract**

## Binding contract

This record describes what an executable surface must bind and validate. It does not claim that a public calculator, package, or production route is deployed.

**Record owner**: Guth Instruments

**Lifecycle**: verified-with-binding-errata

**Evidence ID**: t6-103

**Effect**: Computation or source lookup only

## Input and validation requirements

Zero cells expose undefined or infinite odds ratios and log-based confidence intervals. The specification does not state zero-cell handling, continuity corrections, table-orientation validation, or a literal formula branch. Several intermediate chi-square arithmetic checks also require careful denominator handling; an implementation should validate the Pearson formula and reject or explicitly label undefined results.

## Required corrections

````
[
  {
    "vector": 2,
    "field": "RR_95_CI",
    "wrong": "[0.1774, 1.4091]",
    "correct": "[0.1772, 1.4106]",
    "cause": "micro: 1.96*0.529150=1.037134, she wrote 1.036135"
  }
]
````

## Inspectable interface fixture

The sample below is evidence for interface and validation tests, not a production implementation.

````
{
  "inputs": {
    "a": 30,
    "b": 70,
    "c": 10,
    "d": 90,
    "ci_method": "Wald log scale, 95%, z=1.96",
    "p_method": "uncorrected two-sided Pearson chi-square, df=1"
  },
  "expected_outputs": {
    "RR": 3,
    "RR_95_CI": [
      1.5508,
      5.8034
    ],
    "OR": 3.8571428571,
    "OR_95_CI": [
      1.7666,
      8.4216
    ],
    "pearson_chi_square": 12.5,
    "p_value_approximately": 0.000407
  },
  "working": "Risk exposed = a/(a+b)=30/(30+70)=30/100=0.30. Risk unexposed = c/(c+d)=10/(10+90)=10/100=0.10. RR=0.30/0.10=3.00. SE(log RR)=sqrt(1/30-1/100+1/10-1/100)=sqrt(0.0333333-0.0100000+0.1000000-0.0100000)=sqrt(0.1133333)=0.336650. log(RR)=log(3)=1.098612. Limits on log scale=1.098612 +/- 1.96(0.336650)=1.098612 +/- 0.659834, giving [0.438778,1.758447]. Exponentiating gives RR CI [exp(0.438778),exp(1.758447)]=[1.5508,5.8034]. OR=(a*d)/(b*c)=(30x90)/(70x10)=2700/700=27/7=3.8571428571. SE(log OR)=sqrt(1/30+1/70+1/10+1/90)=sqrt(0.1587302)=0.398410. log(OR)=log(27/7)=1.349927. Limits=1.349927 +/- 1.96(0.398410)=1.349927 +/- 0.780883, so [0.569044,2.130810]. Exponentiating gives [1.7666,8.4216]. Pearson chi-square=n(ad-bc)^2/[(a+b)(c+d)(a+c)(b+d)]=200(30x90-70x10)^2/(100x100x40x160)=200(2000)^2/64000000=12.5. With df=1, p=2[1-Phi(sqrt(12.5))]=2[1-Phi(3.53553)] approximately 0.000407."
}
````

## Other records

[01**Overview**](<https://guthlabs.ai/docs/instruments/relative-risk-odds-ratio-calculator/>)[02**Mechanism**](<https://guthlabs.ai/docs/instruments/relative-risk-odds-ratio-calculator/mechanism/>)[04**Qualification**](<https://guthlabs.ai/docs/instruments/relative-risk-odds-ratio-calculator/qualification/>)

## Sources and evidence

These pointers bind the page to evidence. They do not grant authority or collapse verification into deployment.

- `VERIFIED_LEDGER.json`

- `evidence-tranche6/tranche6-results.json`

- `tranche errata record`
