public static function riskRatio(int $a, int $b, int $c, int $d) : array
{
// Risk ratio
$RR = $a / ($a + $b) / ($c / ($c + $d));
// Standard error of the log relative risk
$ln⟮RR⟯ = log($RR);
$SS{ln⟮RR⟯} = sqrt(1 / $a + 1 / $c - 1 / ($a + $b) - 1 / ($c + $d));
// Z score for 95% confidence interval
$z = 1.96;
// Confidence interval
$ci_lower_bound = exp($ln⟮RR⟯ - $z * $SS{ln⟮RR⟯});
$ci_upper_bound = exp($ln⟮RR⟯ + $z * $SS{ln⟮RR⟯});
// P-value (significance level)
$est = log($RR);
// estimate of effect
$l = log($ci_lower_bound);
// ln CI lower bound
$u = log($ci_upper_bound);
// ln CI upper bound
$SE = ($u - $l) / (2 * self::Z);
// standard error
$z = abs($est / $SE);
// test statistic z
$p = exp(self::NORMAL_LOWER_TAIL_PROBABILITY * $z - self::NORMAL_UPPER_TAIL_PROBABILITY * $z ** 2);
return ['RR' => $RR, 'ci_lower_bound' => $ci_lower_bound, 'ci_upper_bound' => $ci_upper_bound, 'p' => $p];
}