pystatpower.proportion.single.noninferiority
¶
| 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_noninferiority_proportion |
Estimate the required non-inferiority proportion. |
solve_margin |
Estimate the required non-inferiority margin. |
solve_power
¶
solve_power(
*,
proportion: float,
null_proportion: float | None = None,
margin: float | None = None,
noninferiority_proportion: float | None = None,
size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
method: Literal["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool,
) -> float
Calculate the statistical power.
| PARAMETER | DESCRIPTION |
|---|---|
proportion
|
Proportion under the alternative hypothesis.
TYPE:
|
null_proportion
|
Proportion under the null hypothesis. Ignored if
TYPE:
|
margin
|
The non-inferiority margin. Ignored if Tip Regardless of whether
TYPE:
|
noninferiority_proportion
|
The non-inferiority proportion. Required if either
TYPE:
|
size
|
Sample size.
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
|
Whether to apply the continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The statistical power of the test. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
solve_size
¶
solve_size(
*,
proportion: float,
null_proportion: float | None = None,
margin: float | None = None,
noninferiority_proportion: float | None = None,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-p0", "z-phat"] = "z-phat",
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. Ignored if
TYPE:
|
margin
|
The non-inferiority margin. Ignored if Tip Regardless of whether
TYPE:
|
noninferiority_proportion
|
The non-inferiority proportion. Required if either
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
|
Whether to apply the continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The required sample size. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
solve_proportion
¶
solve_proportion(
*,
null_proportion: float | None = None,
margin: float | None = None,
noninferiority_proportion: float | None = None,
size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool = False,
) -> float
Estimate the required proportion under the alternative hypothesis.
| PARAMETER | DESCRIPTION |
|---|---|
null_proportion
|
Proportion under the null hypothesis. Ignored if
TYPE:
|
margin
|
The non-inferiority margin. Ignored if Tip Regardless of whether
TYPE:
|
noninferiority_proportion
|
The non-inferiority proportion. Required if either
TYPE:
|
size
|
Sample size.
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
|
Whether to apply the continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required proportion under the alternative hypothesis. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Notes
The value range of the alternative hypothesis proportion \(p\) is determined by the null hypothesis proportion \(p_0\) and the non-inferiority margin \(\delta\).
If \(\delta < 0\), we have:
If \(\delta > 0\), we have:
solve_null_proportion
¶
solve_null_proportion(
*,
proportion: float,
margin: float,
size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool = False,
) -> float
Estimate the required proportion under the null hypothesis.
| PARAMETER | DESCRIPTION |
|---|---|
proportion
|
Proportion under the alternative hypothesis.
TYPE:
|
margin
|
The non-inferiority margin. Tip Regardless of whether
TYPE:
|
size
|
Sample size.
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
|
Whether to apply the continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required proportion under the null hypothesis. |
Notes
The value range of the null hypothesis proportion \(p_0\) is determined by the alternative hypothesis proportion \(p\) and the non-inferiority margin \(\delta\).
If \(\delta < 0\), we have:
If \(\delta > 0\), we have:
solve_noninferiority_proportion
¶
solve_noninferiority_proportion(
*,
proportion: float,
size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool = False,
) -> float
Estimate the required non-inferiority proportion.
| PARAMETER | DESCRIPTION |
|---|---|
proportion
|
Proportion under the alternative hypothesis.
TYPE:
|
size
|
Sample size.
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
|
Whether to apply the continuity correction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required non-inferiority proportion. |
Notes
The value range of the non-inferiority hypothesis proportion \(p_{\text{noninf}}\) is determined by the alternative hypothesis proportion \(p\).
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(
*,
proportion: float,
null_proportion: float,
size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
method: Literal["z-p0", "z-phat"] = "z-phat",
continuity_correction: bool = False,
) -> float
Estimate the required non-inferiority margin.
| 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. 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
|
Whether to apply the 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 alternative hypothesis proportion \(p\) and the null hypothesis proportion \(p_0\).
If \(\delta < 0\), we have:
If \(\delta > 0\), we have: