Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-199

Poisson Rate Ratio CI

Problem

Return the confidence interval for a Poisson rate ratio exp(ln(RR) +/- z*sqrt(1/e1 + 1/e2)), where RR = (e1/pt1)/(e2/pt2). Return [0.0, 0.0] when any count or person-time is not positive.

Hint

The variance of ln(rate ratio) is 1/events in each group.

Test cases

case 1
in: [20,1000,10,1000,1.96]
expected: [0.9361705989316523,4.27272551024862]
case 2
in: [50,500,25,500,1.96]
expected: [1.2374430460088952,3.2324720017629374]
case 3
in: [5,100,5,100,1.645]
expected: [0.35331709109654824,2.830318785022312]
case 4
in: [0,100,5,100,1.96]
expected: [0,0]
case 5
in: [5,0,5,100,1.96]
expected: [0,0]
Starter codePython
import math
def poisson_rate_ratio_ci(e1, pt1, e2, pt2, z_crit):
    # Your code here
    pass

5 test cases · run your code against them in the editor