Skip to content

Instantly share code, notes, and snippets.

@rtkilian
Created May 12, 2022 21:45
Show Gist options
  • Save rtkilian/14adcae2ddbf644df413c0931dd8718c to your computer and use it in GitHub Desktop.
Save rtkilian/14adcae2ddbf644df413c0931dd8718c to your computer and use it in GitHub Desktop.
from statsmodels.stats.rates import test_poisson_2indep
# Example inputs taken from Gu, Ng, Tang, Schucany 2008: Testing the Ratio of Two Poisson Rates
count1 = 60
exposure1 = 51477.5
count2 = 30
exposure2 = 54308.7
# Calculate test statistic and p-value
stat, p = test_poisson_2indep(count1, exposure1, count2, exposure2, method='etest-wald')
# Interpreation
print('stat=%.3f, p=%.3f' % (stat, p))
if p > 0.05:
print('Do not reject the null hypothesis and conclude the Poisson rates are the same.')
else:
print('Reject the null hypothesis and conclude that the Poisson rates are not the same.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment