跳转至

pystatpower.proportion.independent.inequality

FUNCTION DESCRIPTION
solve_power

Calculate the statistical power.

solve_size

Estimate the required sample size.

solve_treatment_proportion

Estimate the required proportion in the treatment group.

solve_reference_proportion

Estimate the required proportion in the reference group.

solve_power

solve_power(
    *,
    treatment_proportion: float,
    reference_proportion: float,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["two-sided", "one-sided"],
    alpha: float = 0.05,
    method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
    continuity_correction: bool = False,
) -> float

Calculate the statistical power.

PARAMETER DESCRIPTION
treatment_proportion

Proportion in the treatment group.

TYPE: float

reference_proportion

Proportion in the reference group.

TYPE: float

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(p_1 ≠ p_2\)
  • If alternative is 'one-sided', the alternative hypothesis is \(p_1 > p_2\) or \(p_1 < p_2\), depending on the value of treatment_proportion and reference_proportion.

TYPE: Literal['two-sided', 'one-sided']

alpha

Significance level.

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

TYPE: float DEFAULT: 0.05

method

The method used to construct the test statistic.

  • 'z-pooled': Z-test using pooled variance.
  • 'z-unpooled': Z-test using unpooled variance.

TYPE: Literal['z-pooled', 'z-unpooled'] DEFAULT: 'z-unpooled'

continuity_correction

Wether to apply Yates' continuity correction.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
float

The statistical power of the test.

solve_size

solve_size(
    *,
    treatment_proportion: float,
    reference_proportion: float,
    alternative: Literal["two-sided", "one-sided"],
    ratio: float = 1,
    alpha: float = 0.05,
    power: float = 0.8,
    method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
    continuity_correction: bool = False,
) -> tuple[int, int]

Estimate the required sample size.

PARAMETER DESCRIPTION
treatment_proportion

Proportion in the treatment group.

TYPE: float

reference_proportion

Proportion in the reference group.

TYPE: float

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(p_1 ≠ p_2\)
  • If alternative is 'one-sided', the alternative hypothesis is \(p_1 > p_2\) or \(p_1 < p_2\), depending on the value of treatment_proportion and reference_proportion.

TYPE: Literal['two-sided', 'one-sided']

ratio

Ratio of sample sizes in the treatment and reference groups.

TYPE: float DEFAULT: 1

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'one-sided', 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

method

The method used to construct the test statistic.

  • 'z-pooled': Z-test using pooled variance.
  • 'z-unpooled': Z-test using unpooled variance.

TYPE: Literal['z-pooled', 'z-unpooled'] DEFAULT: 'z-unpooled'

continuity_correction

Wether to apply Yates' continuity correction.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
tuple[int, int]

The required sample sizes in the treatment and reference groups, respectively.

solve_treatment_proportion

solve_treatment_proportion(
    *,
    reference_proportion: float,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["two-sided", "one-sided"],
    alpha: float = 0.05,
    power: float = 0.8,
    method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
    continuity_correction: bool = False,
    direction: Literal["greater", "less"],
) -> float

Estimate the required proportion in the treatment group.

PARAMETER DESCRIPTION
reference_proportion

Proportion in the reference group.

TYPE: float

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(p_1 ≠ p_2\)
  • If alternative is 'one-sided', the alternative hypothesis is \(p_1 > p_2\) or \(p_1 < p_2\), depending on the value of treatment_proportion and reference_proportion.

TYPE: Literal['two-sided', 'one-sided']

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'one-sided', 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

method

The method used to construct the test statistic.

  • 'z-pooled': Z-test using pooled variance.
  • 'z-unpooled': Z-test using unpooled variance.

TYPE: Literal['z-pooled', 'z-unpooled'] DEFAULT: 'z-unpooled'

continuity_correction

Wether to apply Yates' continuity correction.

TYPE: bool DEFAULT: False

direction

The direction for the treatment proportion relative to the reference proportion.

  • 'greater': Search for the treatment proportion greater than the reference proportion.
  • 'less': Search for the treatment proportion less than the reference proportion.

TYPE: Literal['greater', 'less']

RETURNS DESCRIPTION
float

The required proportion in the treatment group.

solve_reference_proportion

solve_reference_proportion(
    *,
    treatment_proportion: float,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["two-sided", "one-sided"],
    alpha: float = 0.05,
    power: float = 0.8,
    method: Literal["z-pooled", "z-unpooled"] = "z-unpooled",
    continuity_correction: bool = False,
    direction: Literal["greater", "less"],
) -> float

Estimate the required proportion in the reference group.

PARAMETER DESCRIPTION
treatment_proportion

Proportion in the treatment group.

TYPE: float

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(p_1 ≠ p_2\)
  • If alternative is 'one-sided', the alternative hypothesis is \(p_1 > p_2\) or \(p_1 < p_2\), depending on the value of treatment_proportion and reference_proportion.

TYPE: Literal['two-sided', 'one-sided']

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'one-sided', 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

method

The method used to construct the test statistic.

  • 'z-pooled': Z-test using pooled variance.
  • 'z-unpooled': Z-test using unpooled variance.

TYPE: Literal['z-pooled', 'z-unpooled'] DEFAULT: 'z-unpooled'

continuity_correction

Wether to apply Yates' continuity correction.

TYPE: bool DEFAULT: False

direction

The direction for the treatment proportion relative to the reference proportion.

  • 'greater': Search for the treatment proportion greater than the reference proportion.
  • 'less': Search for the treatment proportion less than the reference proportion.

TYPE: Literal['greater', 'less']

RETURNS DESCRIPTION
float

The required proportion in the reference group.