pystatpower.proportion.single.inequality
¶
Functions:
| Name | Description |
|---|---|
solve_power |
Calculate the statistical power for an inequality test of one proportion. |
solve_size |
Estimate the required sample size for an inequality test of one proportion. |
solve_proportion |
Estimate the required proportion under the alternative hypothesis for an inequality test of one proportion. |
solve_null_proportion |
Estimate the required proportion under the null hypothesis for an inequality test of one proportion. |
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["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool = False,
) -> float
Calculate the statistical power for an inequality test of one proportion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proportion
|
float
|
Proportion under the alternative hypothesis. |
required |
null_proportion
|
float
|
Proportion under the null hypothesis. |
required |
size
|
int
|
Sample size. |
required |
alternative
|
Literal['two-sided', 'greater', 'less']
|
Type of the alternative hypothesis:
|
'two-sided'
|
alpha
|
float
|
Significance level.
|
0.05
|
method
|
Literal['z-p0', 'z-phat']
|
The method used to construct the test statistic.
|
'z-phat'
|
continuity_correction
|
bool
|
Whether to apply the continuity correction. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
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["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool = False,
) -> int
Estimate the required sample size for an inequality test of one proportion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proportion
|
float
|
Proportion under the alternative hypothesis. |
required |
null_proportion
|
float
|
Proportion under the null hypothesis. |
required |
alternative
|
Literal['two-sided', 'greater', 'less']
|
Type of the alternative hypothesis:
|
'two-sided'
|
alpha
|
float
|
Significance level.
|
0.05
|
power
|
float
|
Expected statistical power. 0.8 is a commonly used statistical power. |
0.8
|
method
|
Literal['z-p0', 'z-phat']
|
The method used to construct the test statistic.
|
'z-phat'
|
continuity_correction
|
bool
|
Whether to apply the continuity correction. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
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["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool = False,
direction: Literal["greater", "less"] | None = None,
) -> float
Estimate the required proportion under the alternative hypothesis for an inequality test of one proportion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
null_proportion
|
float
|
Proportion under the null hypothesis. |
required |
size
|
int
|
Sample size. |
required |
alternative
|
Literal['two-sided', 'greater', 'less']
|
Type of the alternative hypothesis:
|
'two-sided'
|
alpha
|
float
|
Significance level.
|
0.05
|
power
|
float
|
Expected statistical power. 0.8 is a commonly used statistical power. |
0.8
|
method
|
Literal['z-p0', 'z-phat']
|
The method used to construct the test statistic.
|
'z-phat'
|
continuity_correction
|
bool
|
Whether to apply the continuity correction. |
False
|
direction
|
Literal['greater', 'less'] | None
|
The direction for the proportion under the alternative hypothesis relative to the proportion under the null hypothesis.
Note
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The required proportion under the alternative hypothesis. |
Raises:
| Type | 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 for an inequality test of one proportion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proportion
|
float
|
Proportion under the alternative hypothesis. |
required |
size
|
int
|
Sample size. |
required |
alternative
|
Literal['two-sided', 'greater', 'less']
|
Type of the alternative hypothesis:
|
'two-sided'
|
alpha
|
float
|
Significance level.
|
0.05
|
power
|
float
|
Expected statistical power. 0.8 is a commonly used statistical power. |
0.8
|
method
|
Literal['z-p0', 'z-phat']
|
The method used to construct the test statistic.
|
'z-phat'
|
continuity_correction
|
bool
|
Whether to apply the continuity correction. |
False
|
direction
|
Literal['greater', 'less'] | None
|
The direction for the proportion under the null hypothesis relative to the proportion under the alternative hypothesis.
Note
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The required proportion under the null hypothesis. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |