All problems
Incidence Rate CI (Byar)
Problem
Return Byar's approximate confidence interval for a Poisson incidence rate. With rate = events/person_time, lower = rate * (1 - 1/(9e) - z/(3*sqrt(e)))^3 and upper = rate * (1 - 1/(9e) + z/(3*sqrt(e)))^3; clamp the lower base at 0. Return [0.0, 0.0] when events or person_time is not positive.
Hint
Byar's approximation is accurate even for small event counts.
Test cases
case 1
in: [100,1000,1.96]
expected: [0.08136179160603568,0.120530503230727]
case 2
in: [10,500,1.96]
expected: [0.009574760431067203,0.03417188692147052]
case 3
in: [1,100,1.96]
expected: [0.00013070134430727016,0.03668097492455418]
case 4
in: [0,100,1.96]
expected: [0,0]
case 5
in: [5,0,1.96]
expected: [0,0]
Starter codePython
def incidence_rate_ci(events, person_time, z_crit):
# Your code here
pass5 test cases · run your code against them in the editor