pystatpower.proportion.independent.noninferiority
¶
| FUNCTION | DESCRIPTION |
|---|---|
solve_power |
Calculate the statistical power. |
solve_size |
Estimate the required sample size. |
solve_treatment_proportion |
Estimate the required proportion in the treatment group. |
solve_reference_proportion |
Estimate the required proportion in the reference group. |
solve_margin |
Estimate the required non-inferiority margin. |
solve_power
¶
solve_power(
*,
treatment_proportion: float,
reference_proportion: float,
margin: float,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
continuity_correction: bool = False,
) -> float
Calculate the statistical power.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_proportion
|
Proportion in the treatment group.
TYPE:
|
reference_proportion
|
Proportion in the reference group.
TYPE:
|
margin
|
The non-inferiority margin. Tip Regardless of whether
TYPE:
|
treatment_size
|
Sample size in the treatment group.
TYPE:
|
reference_size
|
Sample size in the reference group.
TYPE:
|
alternative
|
Type of the alternative hypothesis.
TYPE:
|
alpha
|
Significance level. The non-inferiority test is a one-sided test, with a significance level of 0.025 being commonly used.
TYPE:
|
method
|
The method used to construct the test statistic.
TYPE:
|
continuity_correction
|
Wether to apply Yates' continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The statistical power of the test. |
solve_size
¶
solve_size(
*,
treatment_proportion: float,
reference_proportion: float,
margin: float,
alternative: Literal["greater", "less"],
ratio: float = 1,
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
continuity_correction: bool = False,
) -> tuple[int, int]
Estimate the required sample size.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_proportion
|
Proportion in the treatment group.
TYPE:
|
reference_proportion
|
Proportion in the reference group.
TYPE:
|
margin
|
The non-inferiority margin. Tip Regardless of whether
TYPE:
|
alternative
|
Type of the alternative hypothesis.
TYPE:
|
ratio
|
Ratio of sample sizes in the treatment and reference groups.
TYPE:
|
alpha
|
Significance level. The non-inferiority test is a one-sided test, with a significance level of 0.025 being commonly used.
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
|
Wether to apply Yates' continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int]
|
The required sample sizes in the treatment and reference groups, respectively. |
solve_treatment_proportion
¶
solve_treatment_proportion(
*,
reference_proportion: float,
margin: float,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
continuity_correction: bool = False,
) -> float
Estimate the required proportion in the treatment group.
| PARAMETER | DESCRIPTION |
|---|---|
reference_proportion
|
Proportion in the reference group.
TYPE:
|
margin
|
The non-inferiority margin. Tip Regardless of whether
TYPE:
|
treatment_size
|
Sample size in the treatment group.
TYPE:
|
reference_size
|
Sample size in the reference group.
TYPE:
|
alternative
|
Type of the alternative hypothesis.
TYPE:
|
alpha
|
Significance level. The non-inferiority test is a one-sided test, with a significance level of 0.025 being commonly used.
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
|
Wether to apply Yates' continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required proportion in the treatment group. |
Notes
The value range of the treatment proportion \(p_1\) is determined by the reference proportion \(p_2\) and the non-inferiority margin \(\delta\).
If alternative is 'greater', that is, higher proportions are better, we have:
If alternative is 'less', that is, higher proportions are worse, we have:
solve_reference_proportion
¶
solve_reference_proportion(
*,
treatment_proportion: float,
margin: float,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
continuity_correction: bool = False,
) -> float
Estimate the required proportion in the reference group.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_proportion
|
Proportion in the treatment group.
TYPE:
|
margin
|
The non-inferiority margin. Tip Regardless of whether
TYPE:
|
treatment_size
|
Sample size in the treatment group.
TYPE:
|
reference_size
|
Sample size in the reference group.
TYPE:
|
alternative
|
Type of the alternative hypothesis.
TYPE:
|
alpha
|
Significance level. The non-inferiority test is a one-sided test, with a significance level of 0.025 being commonly used.
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
|
Wether to apply Yates' continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required proportion in the reference group. |
Notes
The value range of the reference proportion \(p_2\) is determined by the treatment proportion \(p_1\) and the non-inferiority margin \(\delta\).
If alternative is 'greater', that is, higher proportions are better, we have:
If alternative is 'less', that is, higher proportions are worse, we have:
solve_margin
¶
solve_margin(
*,
treatment_proportion: float,
reference_proportion: float,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
continuity_correction: bool = False,
) -> float
Estimate the required non-inferiority margin.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_proportion
|
Proportion in the treatment group.
TYPE:
|
reference_proportion
|
Proportion in the reference group.
TYPE:
|
treatment_size
|
Sample size in the treatment group.
TYPE:
|
reference_size
|
Sample size in the reference group.
TYPE:
|
alternative
|
Type of the alternative hypothesis.
TYPE:
|
alpha
|
Significance level. The non-inferiority test is a one-sided test, with a significance level of 0.025 being commonly used.
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
|
Wether to apply Yates' continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required non-inferiority margin. |
Notes
The value range of the non-inferiority margin \(\delta\) is determined by the treatment proportion \(p_1\) and the reference proportion \(p_2\).
If alternative is 'greater', that is, higher proportions are better, we have:
If alternative is 'less', that is, higher proportions are worse, we have: