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