multiple_inference.utils#
Conditional inference utilities.
Functions
|
Compute the expected Wasserstein distance. |
|
Get significant coefficients by performing a Holm-Bonferroni correction. |
|
Compute weighted quantiles. |
- multiple_inference.utils.expected_wasserstein_distance(mean: Sequence[float], cov: ndarray, estimated_means: ndarray, sample_weight: ndarray | None = None, **kwargs: Any) float [source]#
Compute the expected Wasserstein distance.
This loss function computes the Wasserstein distance between the observed means
mean
and the distribution of means you would expect to observe given the estimated population meansestimated_means
.- Parameters:
mean (Numeric1DArray) – (n,) array of conventional point estimates.
cov (np.ndarray) – (n, n) covariance matrix of conventional estimates.
estimated_means (np.ndarray) – (# samples, n) matrix of draws from a distribution of population means.
sample_weight (np.ndarray, optional) – (# samples,) array of sample weights for
estimated_means
. Defaults to None.**kwargs (Any) – Keyword arguments for
scipy.stats.wasserstein_distance
.
- Returns:
Loss.
- Return type:
float
- multiple_inference.utils.holm_bonferroni_correction(filename: str | None = None, results: LikelihoodModelResults | None = None, alpha: float = 0.05) Series [source]#
Get significant coefficients by performing a Holm-Bonferroni correction.
- Parameters:
filename (str, optional) – Name of the csv file with conventional estimates. Defaults to None.
results (LikelihoodModelResults, optional) – Results. Defaults to None.
alpha (float, optional) – Significance level. Defaults to .05.
- Raises:
ValueError – You must specify either
filename
orresults
but not both.- Returns:
Dataframe indicating which coefficients are significant.
- Return type:
pd.DataFrame
- multiple_inference.utils.weighted_quantile(values: ndarray, quantiles: float | Sequence[float], sample_weight: ndarray | None = None, values_sorted: bool = False) ndarray [source]#
Compute weighted quantiles.
- Parameters:
values (np.ndarray) – (n,) array over which to compute quantiles.
quantiles (Union[float, Numeric1DArray]) – (k,) array of quantiles of interest.
sample_weight (np.ndarray, optional) – (n,) array of sample weights. Defaults to None.
values_sorted (bool, optional) – Indicates that
values
have been pre-sorted. Defaults to False.
- Returns:
(k,) array of weighted quantiles.
- Return type:
np.array
- Acknowledgements:
Credit to Stackoverflow.