pystatpower.models.proportion.single.inequality
¶
Functions:
| Name | Description |
|---|---|
solve_power |
Calculate the statistical power for a one-sample proportion test. |
solve_size |
Estimate the required sample size for a one-sample proportion test. |
solve_null_proportion |
Estimate the required proportion under the null hypothesis (\(p_0\)) for a one-sample proportion test. |
solve_proportion |
Estimate the required proportion under the alternative hypothesis (\(p_1\)) for a one-sample proportion test. |
solve_power
¶
solve_power(
*,
null_proportion: float,
proportion: float,
size: int,
alternative: Literal[
"one-sided", "two-sided"
] = "two-sided",
alpha: float = 0.05,
phat: bool = False,
continuity_correction: bool = False,
) -> float
Calculate the statistical power for a one-sample proportion test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
null_proportion
|
float
|
The proportion specified under the null hypothesis (\(p_0\)). Must be in the interval (0, 1). |
required |
proportion
|
float
|
The expected or observed proportion under the alternative hypothesis (\(p_1\)). Must be in the interval (0, 1). |
required |
size
|
int
|
Total number of independent observations (sample size). Must be >= 1. |
required |
alternative
|
Literal['one-sided', 'two-sided']
|
Type iof the alternative hypothesis:
|
'two-sided'
|
alpha
|
float
|
Significance level. |
0.05
|
phat
|
bool
|
Whether or not to use sample proportion to calculate standard deviation. |
False
|
continuity_correction
|
bool
|
Whether or not to apply Yate's continuity correction. |
False
|
Returns:
| Type | Description |
|---|---|
float
|
The calculated power of the test. |
solve_size
¶
solve_size(
*,
null_proportion: float,
proportion: float,
alternative: Literal[
"one-sided", "two-sided"
] = "two-sided",
alpha: float = 0.05,
power: float = 0.8,
phat: bool = False,
continuity_correction: bool = False,
) -> int
Estimate the required sample size for a one-sample proportion test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
null_proportion
|
float
|
The proportion specified under the null hypothesis (\(p_0\)). Must be in the interval (0, 1). |
required |
proportion
|
float
|
The expected proportion under the alternative hypothesis (\(p_1\)). Must be in the interval (0, 1). |
required |
alternative
|
Literal['one-sided', 'two-sided']
|
Type of the alternative hypothesis:
|
'two-sided'
|
alpha
|
float
|
Significance level. |
0.05
|
power
|
float
|
Desired statistical power (1 - Type II error rate). |
0.8
|
phat
|
bool
|
Whether or not to use sample proportion to calculate standard deviation. |
False
|
continuity_correction
|
bool
|
Whether or not to apply Yate's continuity correction. |
False
|
Returns:
| Type | Description |
|---|---|
int
|
The required sample size. |
solve_null_proportion
¶
solve_null_proportion(
*,
proportion: float,
size: int,
alternative: Literal[
"one-sided", "two-sided"
] = "two-sided",
alpha: float = 0.05,
power: float = 0.8,
phat: bool = False,
continuity_correction: bool = False,
search_direction: Literal["below", "above"] = "below",
) -> float
Estimate the required proportion under the null hypothesis (\(p_0\)) for a one-sample proportion test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proportion
|
float
|
The expected proportion under the alternative hypothesis (\(p_1\)). Must be in the interval (0, 1). |
required |
size
|
int
|
Total number of independent observations (sample size). Must be >= 1. |
required |
alternative
|
Literal['one-sided', 'two-sided']
|
Type of the alternative hypothesis:
|
'two-sided'
|
alpha
|
float
|
Significance level. |
0.05
|
power
|
float
|
Desired statistical power (1 - Type II error rate). |
0.8
|
phat
|
bool
|
Whether or not to use sample proportion to calculate standard deviation. |
False
|
continuity_correction
|
bool
|
Whether or not to apply Yate's continuity correction. |
False
|
search_direction
|
Literal['below', 'above']
|
Selection strategy when two valid null proportions exist:
If only one solution exists in (0, 1), this parameter is ignored. |
'below'
|
Returns:
| Type | Description |
|---|---|
float
|
The estimated null proportion (\(p_0\)). |
solve_proportion
¶
solve_proportion(
*,
null_proportion: float,
size: int,
alternative: Literal[
"one-sided", "two-sided"
] = "two-sided",
alpha: float = 0.05,
power: float = 0.8,
phat: bool = False,
continuity_correction: bool = False,
search_direction: Literal["below", "above"] = "above",
) -> float
Estimate the required proportion under the alternative hypothesis (\(p_1\)) for a one-sample proportion test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
null_proportion
|
float
|
The proportion specified under the null hypothesis (\(p_0\)). Must be in the interval (0, 1). |
required |
size
|
int
|
Total number of independent observations (sample size). Must be >= 1. |
required |
alternative
|
Literal['one-sided', 'two-sided']
|
Type of the alternative hypothesis:
|
'two-sided'
|
alpha
|
float
|
Significance level. |
0.05
|
power
|
float
|
Desired statistical power (1 - Type II error rate). |
0.8
|
phat
|
bool
|
Whether or not to use sample proportion to calculate standard deviation. |
False
|
continuity_correction
|
bool
|
Whether or not to apply Yate's continuity correction. |
False
|
search_direction
|
Literal['below', 'above']
|
Selection strategy when two valid alternative proportions exist:
If only one solution exists in (0, 1), this parameter is ignored. |
'above'
|
Returns:
| Type | Description |
|---|---|
float
|
The estimated alternative proportion (\(p_1\)). |