pystatpower.models.proportion.single.ci
¶
Functions:
| Name | Description |
|---|---|
solve_distance |
Calculate the confidence interval width for one proportion or the distance from the proportion to the confidence bound. |
solve_size |
Estimate the required sample size, given either a desired confidence interval width or a desired distance from the proportion to the confidence bound. |
solve_proportion |
Estimate the required proportion, given either a desired confidence interval width or a desired distance from the proportion to the confidence bound. |
solve_distance
¶
solve_distance(
*,
proportion: float,
size: int,
conf_level: float = 0.95,
interval_type: Literal[
"two-sided", "lower one-sided", "upper one-sided"
] = "two-sided",
method: Literal[
"clopper-pearson", "wald", "wilson"
] = "clopper-pearson",
continuity_correction: bool = False,
) -> float
Calculate the confidence interval width for one proportion or the distance from the proportion to the confidence bound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proportion
|
float
|
Proportion. |
required |
size
|
int
|
Sample size. |
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'
|
method
|
Literal['clopper-pearson', 'wald', 'wilson']
|
Method used in calculation of the confidence interval. |
'clopper-pearson'
|
continuity_correction
|
bool
|
Whether or not to apply Yate's continuity correction, only valid for |
False
|
Returns:
| Type | Description |
|---|---|
float
|
The confidence interval width. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
solve_size
¶
solve_size(
*,
proportion: float,
distance: float,
conf_level: float = 0.95,
interval_type: Literal[
"two-sided", "lower one-sided", "upper one-sided"
] = "two-sided",
method: Literal[
"clopper-pearson", "wald", "wilson"
] = "clopper-pearson",
continuity_correction: bool = False,
) -> int
Estimate the required sample size, given either a desired confidence interval width or a desired distance from the proportion to the confidence bound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proportion
|
float
|
Proportion. |
required |
distance
|
float
|
|
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'
|
method
|
Literal['clopper-pearson', 'wald', 'wilson']
|
Method used in calculation of the confidence interval. |
'clopper-pearson'
|
continuity_correction
|
bool | None
|
Whether or not to apply Yate's continuity correction, only valid for |
False
|
Returns:
| Type | Description |
|---|---|
int
|
The required sample size. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
solve_proportion
¶
solve_proportion(
*,
size: int,
distance: float,
conf_level: float = 0.95,
interval_type: Literal[
"two-sided", "lower one-sided", "upper one-sided"
] = "two-sided",
method: Literal[
"clopper-pearson", "wald", "wilson"
] = "clopper-pearson",
continuity_correction: bool = False,
search_direction: Literal["below", "above"] = "above",
) -> float
Estimate the required proportion, given either a desired confidence interval width or a desired distance from the proportion to the confidence bound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Sample size. |
required |
distance
|
float
|
|
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'
|
method
|
Literal['clopper-pearson', 'wald', 'wilson']
|
Method used in calculation of the confidence interval. |
'clopper-pearson'
|
continuity_correction
|
bool | None
|
Whether or not to apply Yate's continuity correction, only valid for |
False
|
search_direction
|
Literal['below', 'above']
|
Direction of the search.
|
'above'
|
Returns:
| Type | Description |
|---|---|
float
|
The required proportion. |