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

instrument mechanism / verified-with-binding-errata

# Relative Risk / Odds Ratio Calculator mechanism

The inspectable method record for Relative Risk / Odds Ratio Calculator, kept separate from implementation and qualification.

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

## Model scope

The core RR and OR point-estimate formulas are standard, but the instrument is not implementation-complete because the CI and p-value algorithms are underspecified and zero-cell behavior is absent. Keep the educational/not-medical-advice label, and explicitly state the cell orientation, count-only input requirement, CI formulas, z critical value, chi-square variant, and zero-cell policy before release.

- The RR formula is standard for a=exposed outcome, b=exposed no outcome, c=unexposed outcome, and d=unexposed no outcome, but the table orientation must be explicitly enforced.

- The OR formula is standard under the same cell definitions.

- The log-SE confidence-interval method is underspecified: it must state whether the interval is the Wald interval, the z critical value (normally 1.96 for 95%), and the exact SE formulas. Standard choices are SE(log RR)=sqrt(1/a-1/(a+b)+1/c-1/(c+d)) and SE(log OR)=sqrt(1/a+1/b+1/c+1/d), followed by exponentiation of the log-scale limits.

- The p-value method is underspecified. Chi-square must specify Pearson versus likelihood-ratio chi-square, continuity correction, degrees of freedom, and one-sided versus two-sided reporting. The vectors below use uncorrected two-sided Pearson chi-square with df=1.

- No zero-cell policy is specified. Without a continuity correction or exact method, log-SE confidence intervals are undefined when any required cell is zero.

- A normal-distribution z-table alone is insufficient to calculate a chi-square p-value unless the implementation explicitly uses the df=1 identity p=2(1-Phi(sqrt(chi-square)).

## Units and conventions

- a, b, c, and d are nonnegative integer counts, not percentages, proportions, rates, or person-time measurements.

- The table is a mutually exclusive 2x2 table: a=exposed with outcome, b=exposed without outcome, c=unexposed with outcome, d=unexposed without outcome.

- RR and OR are dimensionless. Counts must refer to the same observation unit and time/risk period.

- For the nonzero-cell vectors, 95% CIs use natural logarithms, z=1.96, the standard Wald log-SE formulas, and exponentiation back to the original scale.

- The chi-square p-values use the uncorrected Pearson statistic with df=1 and a two-sided upper-tail probability.

## Inspectable vector

One of 4 source-bound review vectors:

````
{
  "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."
}
````

## Failure boundary

**BREAK_CLAIMED** · SELF_FLAGGED

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.

## Other records

[01**Overview**](<https://guthlabs.ai/docs/instruments/relative-risk-odds-ratio-calculator/>)[03**Implementation**](<https://guthlabs.ai/docs/instruments/relative-risk-odds-ratio-calculator/implementation/>)[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`

- `BOUNDARY_HAZARD_CATALOG.json`
