statsmodels.stats.proportion.proportions_ztest¶

statsmodels.stats.proportion.
proportions_ztest
(count, nobs, value=None, alternative='twosided', prop_var=False)[source]¶ test for proportions based on normal (z) test
Parameters: count : integer or array_like
the number of successes in nobs trials. If this is array_like, then the assumption is that this represents the number of successes for each independent sample
nobs : integer
the number of trials or observations, with the same length as count.
value : None or float or array_like
This is the value of the null hypothesis equal to the proportion in the case of a one sample test. In the case of a twosample test, the null hypothesis is that prop[0]  prop[1] = value, where prop is the proportion in the two samples
alternative : string in [‘twosided’, ‘smaller’, ‘larger’]
The alternative hypothesis can be either twosided or one of the one sided tests, smaller means that the alternative hypothesis is
prop < value` and larger means ``prop > value
, or the corresponding inequality for the two sample test.prop_var : False or float in (0, 1)
If prop_var is false, then the variance of the proportion estimate is calculated based on the sample proportion. Alternatively, a proportion can be specified to calculate this variance. Common use case is to use the proportion under the Null hypothesis to specify the variance of the proportion estimate. TODO: change options similar to propotion_ztost ?
Returns: zstat : float
test statistic for the ztest
pvalue : float
pvalue for the ztest
Notes
This uses a simple normal test for proportions. It should be the same as running the mean ztest on the data encoded 1 for event and 0 for no event, so that the sum corresponds to count.
In the one and two sample cases with twosided alternative, this test produces the same pvalue as
proportions_chisquare
, since the chisquare is the distribution of the square of a standard normal distribution. (TODO: verify that this really holds)TODO: add continuity correction or other improvements for small samples.