multiple_inference.bayes.base#
Base classes for Bayesian analysis.
Classes
|
Mixin for Bayesian models. |
|
Results of Bayesian analysis. |
- class multiple_inference.bayes.base.BayesBase(mean: Sequence[float], cov: ndarray, X: Optional[ndarray] = None, endog_names: Optional[str] = None, exog_names: Optional[Sequence[str]] = None, columns: Optional[Union[Sequence[int], Sequence[str], Sequence[bool]]] = None, sort: bool = False, random_state: int = 0)[source]#
Mixin for Bayesian models.
Subclasses
multiple_inference.base.ModelBase.- get_joint_distribution(columns: Optional[Union[Sequence[int], Sequence[str], Sequence[bool]]] = None)[source]#
Get the joint posterior distribution.
- Parameters
columns (ColumnsType, optional) – Selected columns. Defaults to None.
- Returns
Joint distribution.
- Return type
rv_like
- get_joint_prior(columns: Optional[Union[Sequence[int], Sequence[str], Sequence[bool]]] = None)[source]#
Get the joint prior distribution.
- Parameters
columns (ColumnsType, optional) – Selected columns. Defaults to None.
- Returns
Joint distribution.
- Return type
rv_like
- class multiple_inference.bayes.base.BayesResults(*args: Any, n_samples: int = 10000, **kwargs: Any)[source]#
Results of Bayesian analysis.
Inherits from
multiple_inference.base.ResultsBase.- Parameters
*args (Any) – Passed to
multiple_inference.base.ResultsBase.n_samples (int) – Number of samples used for approximations (ranking, likelihood and Wasserstein distance). Defaults to 10000.
**kwargs (Any) – Passed to
multiple_inference.base.ResultsBase.
- distributions#
Marginal posterior distributions.
- Type
List[scipy.stats.norm]
- multivariate_distribution#
Joint posterior distribution.
- Type
scipy.stats.multivariate_normal
- rank_df#
(n, n) dataframe of probabilities that column i has rank j.
- Type
pd.DataFrame
- expected_wasserstein_distance(mean: Optional[Sequence[float]] = None, cov: Optional[ndarray] = None, **kwargs: Any) float[source]#
Compute the Wasserstein distance metric.
This method estimates the Wasserstein distance between the observed distribution (a joint normal characterized by
meanandcov) and the distribution you would expect to observe according to this model.- Parameters
mean (Numeric1DArray, optional) – (# params,) array of sample conventionally estimated means. If None, use the model’s estimated means. Defaults to None.
cov (np.ndarray, optional) – (# params, # params) covaraince matrix for conventionally estimated means. If None, use the model’s estimated covariance matrix. Defaults to None.
**kwargs (Any) – Keyword arguments for
scipy.stats.wasserstein_distance.
- Returns
Expected Wasserstein distance.
- Return type
float
- likelihood(mean: Optional[Sequence[float]] = None, cov: Optional[ndarray] = None) float[source]#
- Parameters
mean (Numeric1DArray, optional) – (# params,) array of sample conventionally estimated means. If None, use the model’s estimated means. Defaults to None.
cov (np.ndarray, optional) – (# params, # params) covaraince matrix for conventionally estimated means. If None, use the model’s estimated covariance matrix. Defaults to None.
- Returns
Likelihood.
- Return type
float
- line_plot(column: Optional[Union[int, str]] = None, alpha: float = 0.05, title: Optional[str] = None, yname: Optional[str] = None, ax=None)[source]#
Create a line plot of the prior, conventional, and posterior estimates.
- Parameters
column (ColumnType, optional) – Selected parameter. Defaults to None.
alpha (float, optional) – Sets the plot width. 0 is as wide as possible, 1 is as narrow as possible. Defaults to .05.
title (str, optional) – Plot title. Defaults to None.
yname (str, optional) – Name of the dependent variable. Defaults to None.
ax (AxesSubplot, optional) – Axis to write on.
- Returns
Plot.
- Return type
AxesSubplot
- rank_matrix_plot(title: Optional[str] = None, **kwargs: Any)[source]#
Plot a heatmap of the rank matrix.
- Parameters
title (str, optional) – Plot title. Defaults to None.
**kwargs (Any) – Passed to
sns.heatmap.
- Returns
Heatmap.
- Return type
AxesSubplot
- reconstruction_point_plot(yname: Optional[str] = None, xname: Optional[Sequence[str]] = None, title: Optional[str] = None, alpha: float = 0.05, ax=None)[source]#
Create point plot of the reconstructed sample means.
Plots the distribution of sample means you would expect to see if this model were correct.
- Parameters
yname (str, optional) – Name of the endogenous variable. Defaults to None.
xname (Sequence[str], optional) – Names of x-ticks. Defaults to None.
title (str, optional) – Plot title. Defaults to None.
alpha – (float, optional): Plot the 1-alpha CI. Defaults to 0.05.
ax – (AxesSubplot, optional): Axis to write on.
- Returns
Plot.
- Return type
plt.axes._subplots.AxesSubplot