跳转至

pystatpower.models.proportion.independent.ci

Functions:

Name Description
solve_distance

Calculate the confidence interval width or the distance from the proportion to the confidence bound for the difference between two independent proportions.

solve_distance

solve_distance(
    *,
    treatment_proportion: float,
    reference_proportion: float,
    treatment_size: int,
    reference_size: int,
    conf_level: float = 0.95,
    interval_type: Literal[
        "two-sided", "lower one-sided", "upper one-sided"
    ] = "two-sided",
    method: Literal["chisq", "chisq_cc"] = "chisq",
) -> float

Calculate the confidence interval width or the distance from the proportion to the confidence bound for the difference between two independent proportions.

Parameters:

Name Type Description Default
treatment_proportion float

Actual proportion in the treatment group (\(p_1\)). Must be between 0 and 1.

required
reference_proportion float

Actual proportion in the reference group (\(p_2\)). Must be between 0 and 1.

required
treatment_size int

Sample size in the treatment group (\(n_1\)). Must be greater than 0.

required
reference_size int

Sample size in the reference group (\(n_2\)). Must be greater than 0.

required
conf_level float

Confidence level.

0.95
interval_type Literal['two-sided', 'lower one-sided', 'upper one-sided']

Type of the confidence interval.

  • two-sided: Two-sided confidence interval.
  • lower one-sided: Lower one-sided confidence interval.
  • upper one-sided: Upper one-sided confidence interval.
'two-sided'
method Literal['chisq', 'chisq_cc']

Method to calculate the confidence interval width or the distance from the proportion to the confidence bound.

  • chisq: Pearson's chi-square method.
  • chisq_cc: Yate's chi-square with continuity correction method.
'chisq'

Returns:

Type Description
float

The confidence interval width or the distance from the proportion to the confidence bound.