跳转至

pystatpower.correlation.inequality

Functions:

Name Description
solve_power

Calculate the statistical power of the difference test between two correlation coefficients.

solve_size

Estimate the required sample size for the difference test between two correlation coefficients.

solve_correlation

Estimate the required correlation coefficient under the alternative hypothesis for the difference test between two correlation coefficients.

solve_null_correlation

Estimete the required correlation coefficient under the null hypothesis for the difference test between two correlation coefficients.

solve_power

solve_power(
    *,
    null_correlation: float,
    correlation: float,
    size: int,
    alternative: Literal[
        "two-sided", "greater", "less"
    ] = "two-sided",
    alpha: float = 0.05,
    bias_adj: bool = False,
) -> float

Calculate the statistical power of the difference test between two correlation coefficients.

Parameters:

Name Type Description Default
null_correlation float

Correlation coefficient under the null hypothesis.

required
correlation float

Correlation coefficient under the alternative hypothesis.

required
size int

Sample size.

required
alternative Literal['two-sided', 'greater', 'less']

Type of alternative hypothesis.

  • 'two-sided': Two-sided alternative hypothesis: \(\rho_1 \neq \rho_0\)
  • 'greater': Upper one-sided alternative hypothesis: \(\rho_1 > \rho_0\)
  • 'less': Lower one-sided alternative hypothesis: \(\rho_1 < \rho_0\)
'two-sided'
alpha float

Significance level.

  • If alternative is 'two-sided', provide the two-sided significance level.
  • If alternative is 'greater' or 'less', provide the one-sided significance level.
0.05
bias_adj bool

Specify whether the bias adjustment is used or not.

False

Returns:

Type Description
float

Power of the test.

solve_size

solve_size(
    *,
    null_correlation: float,
    correlation: float,
    alternative: Literal[
        "two-sided", "greater", "less"
    ] = "two-sided",
    alpha: float = 0.05,
    power: float = 0.8,
    bias_adj: bool = False,
) -> int

Estimate the required sample size for the difference test between two correlation coefficients.

Parameters:

Name Type Description Default
null_correlation float

Correlation coefficient under the null hypothesis.

required
correlation float

Correlation coefficient under the alternative hypothesis.

required
alternative Literal['two-sided', 'greater', 'less']

Type of alternative hypothesis.

  • 'two-sided': Two-sided alternative hypothesis: \(\rho_1 \neq \rho_0\)
  • 'greater': Upper one-sided alternative hypothesis: \(\rho_1 > \rho_0\)
  • 'less': Lower one-sided alternative hypothesis: \(\rho_1 < \rho_0\)
'two-sided'
alpha float

Significance level.

  • If alternative is 'two-sided', provide the two-sided significance level.
  • If alternative is 'greater' or 'less', provide the one-sided significance level.
0.05
power float

Power of the test.

0.8
bias_adj bool

Specify whether the bias adjustment is used or not.

False

Returns:

Type Description
int

The required sample size.

solve_correlation

solve_correlation(
    *,
    null_correlation: float,
    size: int,
    alternative: Literal[
        "two-sided", "greater", "less"
    ] = "two-sided",
    alpha: float = 0.05,
    power: float = 0.8,
    bias_adj: bool = False,
    search_direction: Literal["above", "below"] = "above",
) -> float

Estimate the required correlation coefficient under the alternative hypothesis for the difference test between two correlation coefficients.

Parameters:

Name Type Description Default
null_correlation float

Correlation coefficient under the null hypothesis.

required
size int

Sample size.

required
alternative Literal['two-sided', 'greater', 'less']

Type of alternative hypothesis.

  • 'two-sided': Two-sided alternative hypothesis: \(\rho_1 \neq \rho_0\)
  • 'greater': Upper one-sided alternative hypothesis: \(\rho_1 > \rho_0\)
  • 'less': Lower one-sided alternative hypothesis: \(\rho_1 < \rho_0\)
'two-sided'
alpha float

Significance level.

  • If alternative is 'two-sided', provide the two-sided significance level.
  • If alternative is 'greater' or 'less', provide the one-sided significance level.
0.05
power float

Power of the test.

0.8
bias_adj bool

Specify whether the bias adjustment is used or not.

False
search_direction Literal['above', 'below']

Specify whether to search for the alternative correlation below or above the null correlation.

'above'

Returns:

Type Description
float

required correlation coefficient under the alternative hypothesis.

solve_null_correlation

solve_null_correlation(
    *,
    correlation: float,
    size: int,
    alternative: Literal[
        "two-sided", "greater", "less"
    ] = "two-sided",
    alpha: float = 0.05,
    power: float = 0.8,
    bias_adj: bool = False,
    search_direction: Literal["above", "below"] = "below",
) -> float

Estimete the required correlation coefficient under the null hypothesis for the difference test between two correlation coefficients.

Parameters:

Name Type Description Default
correlation float

Correlation coefficient under the alternative hypothesis.

required
size int

Sample size.

required
alternative Literal['two-sided', 'greater', 'less']

Type of alternative hypothesis.

  • 'two-sided': Two-sided alternative hypothesis: \(\rho_1 \neq \rho_0\)
  • 'greater': Upper one-sided alternative hypothesis: \(\rho_1 > \rho_0\)
  • 'less': Lower one-sided alternative hypothesis: \(\rho_1 < \rho_0\)
'two-sided'
alpha float

Two-sided significance level.

  • If alternative is 'two-sided', provide the two-sided significance level.
  • If alternative is 'less' or 'greater', provide the one-sided significance level.
0.05
power float

Power of the test.

0.8
bias_adj bool

Specify whether the bias adjustment is used or not.

False
search_direction Literal['above', 'below']

Specify whether to search for the null correlation below or above the alternative correlation.

'below'

Returns:

Type Description
float

The required correlation coefficient under the null hypothesis.