pystatpower.mean.independent.superiority
¶
| FUNCTION | DESCRIPTION |
|---|---|
solve_power |
Calculate the statistical power. |
solve_size |
Estimate the required sample size. |
solve_diff |
Estimate the required mean difference. |
solve_treatment_mean |
Estimate the required mean in the treatment group. |
solve_reference_mean |
Estimate the required mean in the reference group. |
solve_margin |
Estimate the required superiority margin. |
solve_treatment_std |
Estimate the required standard deviation in the treatment group. |
solve_reference_std |
Estimate the required standard deviation in the reference group. |
solve_power
¶
solve_power(
*,
treatment_mean: float | None = None,
reference_mean: float | None = None,
diff: float | None = None,
margin: float,
treatment_std: float | None = None,
reference_std: float | None = None,
std: float | None = None,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
dist: Literal["z", "t"] = "t",
equal_var: bool = False,
approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float
Calculate the statistical power.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_mean
|
Mean in the treatment group. If
TYPE:
|
reference_mean
|
Mean in the reference group. If
TYPE:
|
diff
|
Mean difference between treatment and reference group. If both
TYPE:
|
margin
|
The superiority margin. Tip Regardless of whether
TYPE:
|
treatment_std
|
Standard deviation in the treatment group.
TYPE:
|
reference_std
|
Standard deviation in the reference group.
TYPE:
|
std
|
Standard deviation in both groups. This is a convenience parameter that will override If you specify
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 superiority test is a one-sided test, with a significance level of 0.025 being commonly used.
TYPE:
|
dist
|
The distribution used for the test.
TYPE:
|
equal_var
|
Whether to assume equal variances between treatment and reference groups.
TYPE:
|
approx_t_method
|
Approximate t-test method. It is used when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The statistical power of the test. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If all of |
ValueError
|
If |
ValueError
|
If |
solve_size
¶
solve_size(
*,
treatment_mean: float | None = None,
reference_mean: float | None = None,
diff: float | None = None,
margin: float,
treatment_std: float | None = None,
reference_std: float | None = None,
std: float | None = None,
ratio: float = 1,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
dist: Literal["z", "t"] = "t",
equal_var: bool = False,
approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> tuple[int, int]
Estimate the required sample size.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_mean
|
Mean in the treatment group. If
TYPE:
|
reference_mean
|
Mean in the reference group. If
TYPE:
|
diff
|
Mean difference between treatment and reference group. If both
TYPE:
|
margin
|
The superiority margin. Tip Regardless of whether
TYPE:
|
treatment_std
|
Standard deviation in the treatment group.
TYPE:
|
reference_std
|
Standard deviation in the reference group.
TYPE:
|
std
|
Standard deviation in both groups. This is a convenience parameter that will override If you specify
TYPE:
|
ratio
|
Ratio of sample sizes in the treatment and reference groups.
TYPE:
|
alternative
|
Type of the alternative hypothesis.
TYPE:
|
alpha
|
Significance level. The superiority 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:
|
dist
|
The distribution used for the test.
TYPE:
|
equal_var
|
Whether to assume equal variances between treatment and reference groups.
TYPE:
|
approx_t_method
|
Approximate t-test method. It is used when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int]
|
The required sample sizes in the treatment and reference groups, respectively. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If all of |
ValueError
|
If |
ValueError
|
If |
solve_diff
¶
solve_diff(
*,
margin: float,
treatment_std: float | None = None,
reference_std: float | None = None,
std: float | None = None,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
dist: Literal["z", "t"] = "t",
equal_var: bool = False,
approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float
Estimate the required mean difference.
| PARAMETER | DESCRIPTION |
|---|---|
margin
|
The superiority margin. Tip Regardless of whether
TYPE:
|
treatment_std
|
Standard deviation in the treatment group.
TYPE:
|
reference_std
|
Standard deviation in the reference group.
TYPE:
|
std
|
Standard deviation in both groups. This is a convenience parameter that will override If you specify
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 superiority 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:
|
dist
|
The distribution used for the test.
TYPE:
|
equal_var
|
Whether to assume equal variances between treatment and reference groups.
TYPE:
|
approx_t_method
|
Approximate t-test method. It is used when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required difference between the mean in treatment and reference groups. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
ValueError
|
If |
solve_treatment_mean
¶
solve_treatment_mean(
*,
reference_mean: float,
margin: float,
treatment_std: float | None = None,
reference_std: float | None = None,
std: float | None = None,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
dist: Literal["z", "t"] = "t",
equal_var: bool = False,
approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float
Estimate the required mean in the treatment group.
| PARAMETER | DESCRIPTION |
|---|---|
reference_mean
|
Mean in the reference group.
TYPE:
|
margin
|
The superiority margin. Tip Regardless of whether
TYPE:
|
treatment_std
|
Standard deviation in the treatment group.
TYPE:
|
reference_std
|
Standard deviation in the reference group.
TYPE:
|
std
|
Standard deviation in both groups. This is a convenience parameter that will override If you specify
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 superiority 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:
|
dist
|
The distribution used for the test.
TYPE:
|
equal_var
|
Whether to assume equal variances between treatment and reference groups.
TYPE:
|
approx_t_method
|
Approximate t-test method. It is used when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required mean in the treatment group. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
ValueError
|
If |
solve_reference_mean
¶
solve_reference_mean(
*,
treatment_mean: float,
margin: float,
treatment_std: float | None = None,
reference_std: float | None = None,
std: float | None = None,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
dist: Literal["z", "t"] = "t",
equal_var: bool = False,
approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float
Estimate the required mean in the reference group.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_mean
|
Mean in the treatment group.
TYPE:
|
margin
|
The superiority margin. Tip Regardless of whether
TYPE:
|
treatment_std
|
Standard deviation in the treatment group.
TYPE:
|
reference_std
|
Standard deviation in the reference group.
TYPE:
|
std
|
Standard deviation in both groups. This is a convenience parameter that will override If you specify
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 superiority 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:
|
dist
|
The distribution used for the test.
TYPE:
|
equal_var
|
Whether to assume equal variances between treatment and reference groups.
TYPE:
|
approx_t_method
|
Approximate t-test method. It is used when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required mean in the reference group. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
ValueError
|
If |
solve_margin
¶
solve_margin(
*,
treatment_mean: float | None = None,
reference_mean: float | None = None,
diff: float | None = None,
treatment_std: float | None = None,
reference_std: float | None = None,
std: float | None = None,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
dist: Literal["z", "t"] = "t",
equal_var: bool = False,
approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float
Estimate the required superiority margin.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_mean
|
Mean in the treatment group. If
TYPE:
|
reference_mean
|
Mean in the reference group. If
TYPE:
|
diff
|
Mean difference between treatment and reference group. If both
TYPE:
|
treatment_std
|
Standard deviation in the treatment group.
TYPE:
|
reference_std
|
Standard deviation in the reference group.
TYPE:
|
std
|
Standard deviation in both groups. This is a convenience parameter that will override If you specify
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 superiority 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:
|
dist
|
The distribution used for the test.
TYPE:
|
equal_var
|
Whether to assume equal variances between treatment and reference groups.
TYPE:
|
approx_t_method
|
Approximate t-test method. It is used when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required superiority margin for the test.
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If all of |
ValueError
|
If |
ValueError
|
If |
solve_treatment_std
¶
solve_treatment_std(
*,
treatment_mean: float | None = None,
reference_mean: float | None = None,
diff: float | None = None,
margin: float,
reference_std: float | None = None,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
dist: Literal["z", "t"] = "t",
equal_var: bool = True,
approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float
Estimate the required standard deviation in the treatment group.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_mean
|
Mean in the treatment group. If
TYPE:
|
reference_mean
|
Mean in the reference group. If
TYPE:
|
diff
|
Mean difference between treatment and reference group. If both
TYPE:
|
margin
|
The superiority margin. Tip Regardless of whether
TYPE:
|
reference_std
|
Standard deviation 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 superiority 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:
|
dist
|
The distribution used for the test.
TYPE:
|
equal_var
|
Whether to assume equal variances between treatment and reference groups.
TYPE:
|
approx_t_method
|
Approximate t-test method. It is used when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required standard deviation in the treatment group. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If all of |
ValueError
|
If |
solve_reference_std
¶
solve_reference_std(
*,
treatment_mean: float | None = None,
reference_mean: float | None = None,
diff: float | None = None,
margin: float,
treatment_std: float | None = None,
treatment_size: int,
reference_size: int,
alternative: Literal["greater", "less"],
alpha: float = 0.025,
power: float = 0.8,
dist: Literal["z", "t"] = "t",
equal_var: bool = True,
approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float
Estimate the required standard deviation in the reference group.
| PARAMETER | DESCRIPTION |
|---|---|
treatment_mean
|
Mean in the treatment group. If
TYPE:
|
reference_mean
|
Mean in the reference group. If
TYPE:
|
diff
|
Mean difference between treatment and reference group. If both
TYPE:
|
margin
|
The superiority margin. Tip Regardless of whether
TYPE:
|
treatment_std
|
Standard deviation in the treatment group.
TYPE:
|
alternative
|
Type of the alternative hypothesis.
TYPE:
|
alpha
|
Significance level. The superiority 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:
|
dist
|
The distribution used for the test.
TYPE:
|
equal_var
|
Whether to assume equal variances between treatment and reference groups.
TYPE:
|
approx_t_method
|
Approximate t-test method. It is used when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The required standard deviation in the reference group. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If all of |
ValueError
|
If |