Pharmacovigilance
Spontaneous Reporting Analysis
Reporting Odds Ratio
class PharmacovigilanceAnalyzer:
def compute_ror(self, a, b, c, d):
if b == 0 or c == 0: return float('inf')
return (a * d) / (b * c)
def compute_chi_square(self, a, b, c, d):
n = a + b + c + d
expected = [(a+b)*(a+c)/n, (a+b)*(b+d)/n, (c+d)*(a+c)/n, (c+d)*(b+d)/n]
return sum((o - e)**2 / e for o, e in zip([a, b, c, d], expected))