pystatpower.proportion.single.inequality
¶
| FUNCTION | DESCRIPTION |
|---|---|
solve_power |
Calculate the statistical power. |
solve_size |
Estimate the required sample size. |
solve_proportion |
Estimate the required proportion under the alternative hypothesis. |
solve_null_proportion |
Estimate the required proportion under the null hypothesis. |
solve_power
¶
solve_power(
*,
proportion: float,
null_proportion: float,
size: int,
alternative: Literal["two-sided", "greater", "less"] = "two-sided",
alpha: float = 0.05,
method: Literal["exact", "z-p0", "z-phat"] = "exact",
continuity_correction: bool = False,
) -> float
Calculate the statistical power.
| PARAMETER | DESCRIPTION |
|---|---|
proportion
|
Proportion under the alternative hypothesis.
TYPE:
|
null_proportion
|
Proportion under the null hypothesis.
TYPE:
|
size
|
Sample size.
TYPE:
|
alternative
|
Type of the alternative hypothesis:
TYPE:
|
alpha
|
Significance level.
TYPE:
|
method
|
The method used to construct the test statistic.
TYPE:
|
continuity_correction
|
Whether to apply the continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The statistical power of the test. |
solve_size
¶
solve_size(
*,
proportion: float,
null_proportion: float,
alternative: Literal["two-sided", "greater", "less"] = "two-sided",
alpha: float = 0.05,
power: float = 0.8,
method: Literal["exact", "z-p0", "z-phat"] = "exact",
continuity_correction: bool = False,
) -> int
Estimate the required sample size.
| PARAMETER | DESCRIPTION |
|---|---|
proportion
|
Proportion under the alternative hypothesis.
TYPE:
|
null_proportion
|
Proportion under the null hypothesis.
TYPE:
|
alternative
|
Type of the alternative hypothesis:
TYPE:
|
alpha
|
Significance level.
TYPE:
|
power
|
Expected statistical power. 0.8 is a commonly used value for statistical power.
TYPE:
|
method
|
The method used to construct the test statistic.
TYPE:
|
continuity_correction
|
Whether to apply the continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The required sample size. |
solve_proportion
¶
solve_proportion(
*,
null_proportion: float,
size: int,
alternative: Literal["two-sided", "greater", "less"] = "two-sided",
alpha: float = 0.05,
power: float = 0.8,
method: Literal["exact", "z-p0", "z-phat"] = "exact",
continuity_correction: bool = False,
direction: Literal["greater", "less"] | None = None,
) -> float
Estimate the required proportion under the alternative hypothesis.
| PARAMETER | DESCRIPTION |
|---|---|
null_proportion
|
Proportion under the null hypothesis.
TYPE:
|
size
|
Sample size.
TYPE:
|
alternative
|
Type of the alternative hypothesis:
TYPE:
|
alpha
|
Significance level.
TYPE:
|
power
|
Expected statistical power. 0.8 is a commonly used value for statistical power.
TYPE:
|
method
|
The method used to construct the test statistic.
TYPE:
|
continuity_correction
|
Whether to apply the continuity correction.
TYPE:
|
direction
|
The direction for the proportion under the alternative hypothesis relative to the proportion under the null hypothesis.
Note
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required proportion under the alternative hypothesis. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
solve_null_proportion
¶
solve_null_proportion(
*,
proportion: float,
size: int,
alternative: Literal["two-sided", "greater", "less"] = "two-sided",
alpha: float = 0.05,
power: float = 0.8,
method: Literal["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool = False,
direction: Literal["greater", "less"] | None = None,
) -> float
Estimate the required proportion under the null hypothesis.
| PARAMETER | DESCRIPTION |
|---|---|
proportion
|
Proportion under the alternative hypothesis.
TYPE:
|
size
|
Sample size.
TYPE:
|
alternative
|
Type of the alternative hypothesis:
TYPE:
|
alpha
|
Significance level.
TYPE:
|
power
|
Expected statistical power. 0.8 is a commonly used value for statistical power.
TYPE:
|
method
|
The method used to construct the test statistic.
TYPE:
|
continuity_correction
|
Whether to apply the continuity correction.
TYPE:
|
direction
|
The direction for the proportion under the null hypothesis relative to the proportion under the alternative hypothesis.
Note
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required proportion under the null hypothesis. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Info
This solver does not support the exact test method, as minor fluctuations in null_proportion can cause
oscillations in power, making it impossible to obtain an accurate null_proportion value under the given
parameters.