code: def test_rate_poisson_r():
      count, nobs = 15, 400
  
      # DescTools
      # PoissonCI(x=15, n=400, method = c("exact","score", "wald", "byar"))
      # exact 0.0375 0.0209884653319583 0.0618505471787146
      # score 0.0375 0.0227264749053794 0.0618771721463559
      # wald  0.0375 0.0185227303217751 0.0564772696782249
      # byar  0.0375 0.0219084369245707 0.0602933510943048
  
      # > rr = poisson.exact(15, 400, r=0.05, tsmethod="central")
      # > rr$p.value
      # > rr$conf.int
      pv2 = 0.313026269279486
      ci2 = (0.0209884653319583, 0.0618505471787146)
      rt = smr.test_poisson(count, nobs, value=0.05, method="exact-c")
      ci = confint_poisson(count, nobs, method="exact-c")
      assert_allclose(rt.pvalue, pv2, rtol=1e-12)
      assert_allclose(ci, ci2, rtol=1e-12)
  
      # R package ratesci
      # sr = scoreci(15, 400, contrast="p", distrib = "poi", skew=FALSE,
      #      theta0=0.05)
      # pval computed from 2 * min(pval_left, pval_right)
      pv2 = 0.263552477282973
      # ci2 = (0.022726, 0.061877)  # no additional digits available
      ci2 = (0.0227264749053794, 0.0618771721463559)  # from DescTools
      rt = smr.test_poisson(count, nobs, value=0.05, method="score")
      ci = confint_poisson(count, nobs, method="score")
      assert_allclose(rt.pvalue, pv2, rtol=1e-12)
      assert_allclose(ci, ci2, rtol=1e-12)
  
      # > jeffreysci(15, 400, distrib = "poi")
      ci2 = (0.0219234232268444, 0.0602898619930649)
      ci = confint_poisson(count, nobs, method="jeff")
      assert_allclose(ci, ci2, rtol=1e-12)
  
      # from DescTools
      ci2 = (0.0185227303217751, 0.0564772696782249)
      ci = confint_poisson(count, nobs, method="wald")
      assert_allclose(ci, ci2, rtol=1e-12)
  
      # from ratesci
      # rateci(15, 400, distrib = "poi")
      # I think their lower ci is wrong, it also doesn't match for exact_c
      ci2 = (0.0243357599260795, 0.0604627555786095)
      ci = confint_poisson(count, nobs, method="midp-c")
      assert_allclose(ci[1], ci2[1], rtol=1e-5)
  
imports: import pytest
  import warnings
  import numpy
  from numpy import arange
  from numpy.testing import assert_allclose, assert_equal
  from scipy import stats
  import statsmodels.stats.rates
  from statsmodels.stats.rates import confint_poisson, tolerance_int_poisson, confint_quantile_poisson, etest_poisson_2indep, confint_poisson_2indep, nonequivalence_poisson_2indep, power_poisson_ratio_2indep, power_equivalence_poisson_2indep, power_poisson_diff_2indep, power_equivalence_neginb_2indep, power_negbin_ratio_2indep, method_names_poisson_1samp, method_names_poisson_2indep
label_desc: Use image node_id 2 for calling a global function with example usage: test_rate_poisson_r() without return types