跳转至

pystatpower.proportion.single.equivalence

FUNCTION DESCRIPTION
solve_power

Calculate the statistical power.

solve_size

Estimate the required sample size.

solve_power

solve_power(
    *,
    proportion: float,
    null_proportion: float,
    margin_lower: float,
    margin_upper: float,
    size: int,
    alpha: float = 0.025,
    method: Literal["z-p0", "z-phat"] = "z-phat",
    continuity_correction: bool = False,
) -> float

Calculate the statistical power.

PARAMETER DESCRIPTION
proportion

Proportion under the alternative hypothesis.

TYPE: float

null_proportion

Proportion under the null hypothesis.

TYPE: float

margin_lower

The lower equivalence margin, must be a negative value.

TYPE: float

margin_upper

The upper equivalence margin, must be a positive value.

TYPE: float

size

Sample size.

TYPE: int

alpha

Significance level.

The equivalence test is a two one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

method

The method used to construct the test statistic.

  • 'z-p0': Standard normal distribution (large sample approximation), using p0 to calculate the variance.
  • 'z-phat': Standard normal distribution (large sample approximation), using phat to calculate the variance.

TYPE: Literal['z-p0', 'z-phat'] DEFAULT: 'z-phat'

continuity_correction

Whether to apply the continuity correction.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
float

The statistical power of the test.

solve_size

solve_size(
    *,
    proportion: float,
    null_proportion: float,
    margin_lower: float,
    margin_upper: float,
    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: float

null_proportion

Proportion under the null hypothesis.

TYPE: float

margin_lower

The lower equivalence margin, must be a negative value.

TYPE: float

margin_upper

The upper equivalence margin, must be a positive value.

TYPE: float

alpha

Significance level.

The equivalence test is a two one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

method

The method used to construct the test statistic.

  • 'z-p0': Standard normal distribution (large sample approximation), using p0 to calculate the variance.
  • 'z-phat': Standard normal distribution (large sample approximation), using phat to calculate the variance.

TYPE: Literal['z-p0', 'z-phat'] DEFAULT: 'z-phat'

continuity_correction

Whether to apply the continuity correction.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
int

The required sample size.