Test for proportions based on normal (z) test
Parameters: | count : integer or array_like
nobs : integer or array-like
value : float, array_like or None, optional
alternative : string in [‘two-sided’, ‘smaller’, ‘larger’]
prop_var : False or float in (0, 1)
|
---|---|
Returns: | zstat : float
p-value : float
|
Notes
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 the 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.
Examples
>>> count = 5
>>> nobs = 83
>>> value = .05
>>> stat, pval = proportions_ztest(count, nobs, value)
>>> print('{0:0.3f}'.format(pval))
0.695
>>> import numpy as np
>>> from statsmodels.stats.proportion import proportions_ztest
>>> count = np.array([5, 12])
>>> nobs = np.array([83, 99])
>>> stat, pval = proportions_ztest(counts, nobs)
>>> print('{0:0.3f}'.format(pval))
0.159