pystatpower.models.proportion.independent.inequality
¶
Functions:
| Name | Description |
|---|---|
solve_power |
Calculate the power for an inequality test of two independent proportions. |
solve_size |
Estimate the sample size required for an inequality test of two independent proportions. |
solve_treatment_proportion |
Estimate the proportion required in the treatment group for an inequality test of two independent proportions. |
solve_reference_proportion |
Estimate the proportion required in the reference group for an inequality test of two independent proportions. |
solve_power
¶
solve_power(*, treatment_proportion: float, reference_proportion: float, treatment_size: float, reference_size: float, alternative: Literal['one-sided', 'two-sided'], alpha: float = 0.05, pooled: bool = False, continuity_correction: bool = False) -> float
Calculate the power for an inequality test of two independent proportions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
treatment_proportion
|
float
|
Actual proportion in the treatment group (\(p_1\)). Must be between 0 and 1. |
required |
reference_proportion
|
float
|
Actual proportion in the reference group (\(p_2\)). Must be between 0 and 1. |
required |
alternative
|
Literal['one-sided', 'two-sided']
|
Type of alternative hypothesis.
|
required |
treatment_size
|
float
|
Sample size for the treatment group (\(n_1\)). |
required |
reference_size
|
float
|
Sample size for the reference group (\(n_2\)). |
required |
alpha
|
float
|
Significance level. Defaults to 0.05. |
0.05
|
pooled
|
bool
|
If True, use the pooled variance estimator (\(\bar{p}\)) under the null hypothesis. Defaults to False. |
False
|
continuity_correction
|
bool
|
If True, applies Yates' continuity correction. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Power of the test. |
solve_size
¶
solve_size(*, treatment_proportion: float, reference_proportion: float, alternative: Literal['one-sided', 'two-sided'], ratio: float = 1, alpha: float = 0.05, power: float = 0.8, pooled: bool = False, continuity_correction: bool = False) -> tuple[int, int]
Estimate the sample size required for an inequality test of two independent proportions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
treatment_proportion
|
float
|
Expected proportion in the treatment group (\(p_1\)). Must be between 0 and 1. |
required |
reference_proportion
|
float
|
Expected proportion in the reference group (\(p_2\)). Must be between 0 and 1. |
required |
alternative
|
Literal['one-sided', 'two-sided']
|
Type of alternative hypothesis.
|
required |
ratio
|
float
|
Ratio of treatment sample size to reference sample size (\(k = n_1 / n_2\)). Defaults to 1. |
1
|
alpha
|
float
|
Significance level. Defaults to 0.05. |
0.05
|
power
|
float
|
Desired statistical power. Defaults to 0.80. |
0.8
|
pooled
|
bool
|
If True, use the pooled variance estimator (\(\bar{p}\)) under the null hypothesis. Defaults to False. |
False
|
continuity_correction
|
bool
|
If True, applies Yates' continuity correction. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
tuple[int, int]: The required sample sizes for the treatment and reference groups, respectively. |
solve_treatment_proportion
¶
solve_treatment_proportion(*, reference_proportion: float, treatment_size: float, reference_size: float, alternative: Literal['one-sided', 'two-sided'], alpha: float = 0.05, power: float = 0.8, pooled: bool = False, continuity_correction: bool = False, search_direction: Literal['lower', 'upper'] = 'upper') -> float
Estimate the proportion required in the treatment group for an inequality test of two independent proportions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_proportion
|
float
|
Expected proportion in the reference group (\(p_2\)). Must be between 0 and 1. |
required |
treatment_size
|
float
|
Sample size for the treatment group (\(n_1\)). |
required |
reference_size
|
float
|
Sample size for the reference group (\(n_2\)). |
required |
alternative
|
Literal['one-sided', 'two-sided']
|
Type of alternative hypothesis.
|
required |
alpha
|
float
|
Significance level. Defaults to 0.05. |
0.05
|
power
|
float
|
Desired statistical power. Defaults to 0.80. |
0.8
|
pooled
|
bool
|
If True, use the pooled variance estimator (\(\bar{p}\)) under the null hypothesis. Defaults to False. |
False
|
continuity_correction
|
bool
|
If True, applies Yates' continuity correction. Defaults to False. |
False
|
search_direction
|
Literal['lower', 'upper']
|
Which solution to search for relative to \(p_2\).
|
'upper'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The required proportion in the treatment group. |
solve_reference_proportion
¶
solve_reference_proportion(*, treatment_proportion: float, treatment_size: float, reference_size: float, alternative: Literal['one-sided', 'two-sided'], alpha: float = 0.05, power: float = 0.8, pooled: bool = False, continuity_correction: bool = False, search_direction: Literal['lower', 'upper'] = 'lower') -> float
Estimate the proportion required in the reference group for an inequality test of two independent proportions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
treatment_proportion
|
float
|
Expected proportion in the treatment group (\(p_1\)). Must be between 0 and 1. |
required |
treatment_size
|
float
|
Sample size for the treatment group (\(n_1\)). |
required |
reference_size
|
float
|
Sample size for the reference group (\(n_2\)). |
required |
alternative
|
Literal['one-sided', 'two-sided']
|
Type of alternative hypothesis.
|
required |
alpha
|
float
|
If True, use the pooled variance estimator (\(\bar{p}\)) under the null hypothesis. Defaults to False. |
0.05
|
power
|
float
|
Desired statistical power. Defaults to 0.80. |
0.8
|
pooled
|
bool
|
If True, use the pooled variance estimator. Defaults to False. |
False
|
continuity_correction
|
bool
|
If True, applies Yates' continuity correction. Defaults to False. |
False
|
search_direction
|
Literal['lower', 'upper']
|
Which solution to search for relative to \(p_1\).
|
'lower'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The required proportion in the reference group. |