跳转至

pystatpower.correlation.inequality

FUNCTION DESCRIPTION
solve_power

Calculate the statistical power.

solve_size

Estimate the required sample size.

solve_correlation

Estimate the required correlation coefficient under the alternative hypothesis.

solve_null_correlation

Estimate the required correlation coefficient under the null hypothesis.

solve_power

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

Calculate the statistical power.

PARAMETER DESCRIPTION
null_correlation

Correlation coefficient under the null hypothesis.

TYPE: float

correlation

Correlation coefficient under the alternative hypothesis.

TYPE: float

size

Sample size.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\rho \neq \rho_0\).
  • If alternative is 'greater', the alternative hypothesis is \(\rho > \rho_0\).
  • If alternative is 'less', the alternative hypothesis is \(\rho < \rho_0\).

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

RETURNS DESCRIPTION
float

The statistical 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,
) -> int

Estimate the required sample size.

PARAMETER DESCRIPTION
null_correlation

Correlation coefficient under the null hypothesis.

TYPE: float

correlation

Correlation coefficient under the alternative hypothesis.

TYPE: float

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\rho \neq \rho_0\).
  • If alternative is 'greater', the alternative hypothesis is \(\rho > \rho_0\).
  • If alternative is 'less', the alternative hypothesis is \(\rho < \rho_0\).

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

RETURNS 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,
    direction: Literal["greater", "less"] | None = None,
) -> float

Estimate the required correlation coefficient under the alternative hypothesis.

PARAMETER DESCRIPTION
null_correlation

Correlation coefficient under the null hypothesis.

TYPE: float

size

Sample size.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\rho \neq \rho_0\).
  • If alternative is 'greater', the alternative hypothesis is \(\rho > \rho_0\).
  • If alternative is 'less', the alternative hypothesis is \(\rho < \rho_0\).

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

direction

The direction for the correlation coefficient under the alternative hypothesis relative to the correlation coefficient under the null hypothesis.

  • 'greater': Search for the alternative correlation coefficient greater than the null correlation coefficient.
  • 'less': Search for the alternative correlation coefficient less than the null correlation coefficient.

Note

  • If alternative is 'two-sided', this parameter is required.
  • If alternative is 'greater', the search direction is automatically inferred to be 'greater', and this parameter is ignored.
  • If alternative is 'less', the search direction is automatically inferred to be 'less', and this parameter is ignored.

TYPE: Literal['greater', 'less'] | None DEFAULT: None

RETURNS DESCRIPTION
float

The required correlation coefficient under the alternative hypothesis.

RAISES DESCRIPTION
ValueError

If alternative is 'two-sided' and direction is omitted.

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,
    direction: Literal["greater", "less"] | None = None,
) -> float

Estimate the required correlation coefficient under the null hypothesis.

PARAMETER DESCRIPTION
correlation

Correlation coefficient under the alternative hypothesis.

TYPE: float

size

Sample size.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\rho \neq \rho_0\).
  • If alternative is 'greater', the alternative hypothesis is \(\rho > \rho_0\).
  • If alternative is 'less', the alternative hypothesis is \(\rho < \rho_0\).

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

direction

The direction for the correlation coefficient under the null hypothesis relative to the correlation coefficient under the alternative hypothesis.

  • 'greater': Search for the null correlation coefficient greater than the alternative correlation coefficient.
  • 'less': Search for the null correlation coefficient less than the alternative correlation coefficient.

Note

  • If alternative is 'two-sided', this parameter is required.
  • If alternative is 'greater', the search direction is automatically inferred to be 'less', and this parameter is ignored.
  • If alternative is 'less', the search direction is automatically inferred to be 'greater', and this parameter is ignored.

TYPE: Literal['greater', 'less'] | None DEFAULT: None

RETURNS DESCRIPTION
float

The required correlation coefficient under the null hypothesis.

RAISES DESCRIPTION
ValueError

If alternative is 'two-sided' and direction is omitted.