proportions_ztest(count, nobs, value=None, alternative='two-sided', prop_var=False)¶
test for proportions based on normal (z) test
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 two-sample test, the null hypothesis is that prop - prop = value, where prop is the proportion in the two samples
alternative : string in [‘two-sided’, ‘smaller’, ‘larger’]
The alternative hypothesis can be either two-sided 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 ?
zstat : float
test statistic for the z-test
p-value : float
p-value for the z-test
This uses a simple normal test for proportions. It should be the same as running the mean z-test 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 two-sided alternative, this test produces the same p-value 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.