statsmodels.stats.rates.test_poisson_2indep

statsmodels.stats.rates.test_poisson_2indep(count1, exposure1, count2, exposure2, value=None, ratio_null=None, method=None, compare='ratio', alternative='two-sided', etest_kwds=None)[source]

Test for comparing two sample Poisson intensity rates.

Rates are defined as expected count divided by exposure.

The Null and alternative hypothesis for the rates, rate1 and rate2, of two independent Poisson samples are

for compare = ‘diff’

  • H0: rate1 - rate2 - value = 0

  • H1: rate1 - rate2 - value != 0 if alternative = ‘two-sided’

  • H1: rate1 - rate2 - value > 0 if alternative = ‘larger’

  • H1: rate1 - rate2 - value < 0 if alternative = ‘smaller’

for compare = ‘ratio’

  • H0: rate1 / rate2 - value = 0

  • H1: rate1 / rate2 - value != 0 if alternative = ‘two-sided’

  • H1: rate1 / rate2 - value > 0 if alternative = ‘larger’

  • H1: rate1 / rate2 - value < 0 if alternative = ‘smaller’

Parameters:
count1 : int

Number of events in first sample, treatment group.

exposure1 : float

Total exposure (time * subjects) in first sample.

count2 : int

Number of events in second sample, control group.

exposure2 : float

Total exposure (time * subjects) in second sample.

ratio_null : float

Ratio of the two Poisson rates under the Null hypothesis. Default is 1. Deprecated, use value instead.

Deprecated since version 0.14.0: Use value instead.

value : float

Value of the ratio or difference of 2 independent rates under the null hypothesis. Default is equal rates, i.e. 1 for ratio and 0 for diff.

Added in version 0.14.0: Replacement for ratio_null.

method : string

Method for the test statistic and the p-value. Defaults to ‘score’. see Notes.

ratio:

  • ’wald’: method W1A, wald test, variance based on observed rates

  • ’score’: method W2A, score test, variance based on estimate under the Null hypothesis

  • ’wald-log’: W3A, uses log-ratio, variance based on observed rates

  • ’score-log’ W4A, uses log-ratio, variance based on estimate under the Null hypothesis

  • ’sqrt’: W5A, based on variance stabilizing square root transformation

  • ’exact-cond’: exact conditional test based on binomial distribution

    This uses binom_test which is minlike in the two-sided case.

  • ’cond-midp’: midpoint-pvalue of exact conditional test

  • ’etest’ or ‘etest-score: etest with score test statistic

  • ’etest-wald’: etest with wald test statistic

diff:

  • ’wald’,

  • ’waldccv’

  • ’score’

  • ’etest-score’ or ‘etest: etest with score test statistic

  • ’etest-wald’: etest with wald test statistic

compare : {'diff', 'ratio'}

Default is “ratio”. If compare is ratio, then the hypothesis test is for the rate ratio defined by ratio = rate1 / rate2. If compare is diff, then the hypothesis test is for diff = rate1 - rate2.

alternative : {"two-sided" (default), "larger", smaller}

The alternative hypothesis, H1, has to be one of the following

  • ’two-sided’: H1: ratio, or diff, of rates is not equal to value

  • ’larger’ : H1: ratio, or diff, of rates is larger than value

  • ’smaller’ : H1: ratio, or diff, of rates is smaller than value

etest_kwds : dictionary

Additional optional parameters to be passed to the etest_poisson_2indep function, namely y_grid.

Returns:

results – The two main attributes are test statistic statistic and p-value pvalue.

Return type:

instance of HolderTuple class

Notes

The hypothesis tests for compare=”ratio” are based on Gu et al 2018. The e-tests are also based on …

  • ‘wald’: method W1A, wald test, variance based on separate estimates

  • ‘score’: method W2A, score test, variance based on estimate under Null

  • ‘wald-log’: W3A, wald test for log transformed ratio

  • ‘score-log’ W4A, score test for log transformed ratio

  • ‘sqrt’: W5A, based on variance stabilizing square root transformation

  • ‘exact-cond’: exact conditional test based on binomial distribution

  • ‘cond-midp’: midpoint-pvalue of exact conditional test

  • ‘etest’: etest with score test statistic

  • ‘etest-wald’: etest with wald test statistic

The hypothesis test for compare=”diff” are mainly based on Ng et al 2007 and …

  • wald

  • score

  • etest-score

  • etest-wald

Note the etests use the constraint maximum likelihood estimate (cmle) as parameters for the underlying Poisson probabilities. The constraint cmle parameters are the same as in the score test. The E-test in Krishnamoorty and Thomson uses a moment estimator instead of the score estimator.

References