statsmodels.stats.proportion.samplesize_proportions_2indep_onetail

statsmodels.stats.proportion.samplesize_proportions_2indep_onetail(diff, prop2, power, ratio=1, alpha=0.05, value=0, alternative='two-sided')[source]

required sample size assuming normal distribution based on one tail

This uses an explicit computation for the sample size that is required to achieve a given power corresponding to the appropriate tails of the normal distribution. This ignores the far tail in a two-sided test which is negligible in the common case when alternative and null are far apart.

Parameters:
difffloat

Difference between proportion 1 and 2 under the alternative

prop2float

proportion for the reference case, prop2, proportions for the first case will be computing using p2 and diff p1 = p2 + diff

powerfloat

Power for which sample size is computed.

ratiofloat

Sample size ratio, nobs2 = ratio * nobs1

alphafloat in interval (0,1)

Significance level, e.g. 0.05, is the probability of a type I error, that is wrong rejections if the Null Hypothesis is true.

valuefloat

Currently only value=0, i.e. equality testing, is supported

alternativestr, ‘two-sided’ (default), ‘larger’, ‘smaller’

Alternative hypothesis whether the power is calculated for a two-sided (default) or one sided test. In the case of a one-sided alternative, it is assumed that the test is in the appropriate tail.

Returns:
nobs1float

Number of observations in sample 1.