diagnostics¶
- autocorrelation_plot(posteriors: dict, max_lags: int = 30) None¶
Plots the auto-correlation for each Markov chain for each regression variable. The plot shows the auto-correlation trend from lag
0(when auto-correlation is always1) up tomax_lags. The plot layout has number of rows equal to the number of regression variables and a number of columns equal to the number of chains.Parameters¶
- posteriorsdict
Posterior samples. Posteriors and relative samples are key-value pairs. Each sample is a
numpy.ndarraywith a number of rows equal to the number of iterations and a number of columns equal to the number of Markov chains.- max_lagsint, optional
Maximum number of lags to which compute the auto-correlation. The default is
30.
Raises¶
- TypeError
If
posteriorsis not adict,if a posterior sample is not a
numpy.ndarray,if
max_lagsis not aint.
- KeyError
If
posteriorsdoes not containinterceptkey.- ValueError
If a posterior sample is an empty
numpy.ndarray,if
max_lagsis less or equal to0.
See Also¶
baypy.diagnostics.functions.autocorrelation_summary()baypy.diagnostics.functions.effective_sample_size()
- autocorrelation_summary(posteriors: dict, lags: list | None = None, print_summary: bool = True) DataFrame¶
Prints the auto-correlation summary for each regression variable. The summary reports the auto-correlation values at the lags listed in
lags.Parameters¶
- posteriorsdict
Posterior samples. Posteriors and relative samples are key-value pairs. Each sample is a
numpy.ndarraywith a number of rows equal to the number of iterations and a number of columns equal to the number of Markov chains.- lagslist, optional
List of the lags to which compute the auto-correlation. It cannot be an empty
list. It must contain only positive integers. The default is[0, 1, 5, 10, 30].- print_summarybool, optional
If
Trueprints the autocorrelation summary report. Default isTrue.
Returns¶
- pd.DataFrame
The dataframe with a number of row equal to the number of element in
lagsand a number of columns equal to the number of model variables. Lags are reported in dataframe index.
Raises¶
- TypeError
If
posteriorsis not adict,if a posterior sample is not a
numpy.ndarray,if
lagsis not alist,if
lagsdoes not contain onlyint,if
print_summaryis not abool.
- KeyError
If
posteriorsdoes not containinterceptkey.- ValueError
If a posterior sample is an empty
numpy.ndarray,if
lagsis an emptylist,if a value in
lagsis a negativeint.
See Also¶
baypy.diagnostics.functions.autocorrelation_plot()baypy.diagnostics.functions.effective_sample_size()Notes¶
The reported auto-correlation for each variable is a mean of auto-correlations for the chains of that variable, for each chain.
- effective_sample_size(posteriors: dict, print_summary: bool = True) DataFrame¶
Computes and prints the effective number of sample for each posterior.
Parameters¶
- posteriorsdict
Posterior samples. Posteriors and relative samples are key-value pairs. Each sample is a
numpy.ndarraywith a number of rows equals to the number of iterations and a number of columns equal to the number of Markov chains.- print_summarybool, optional
If
Trueprints the effective sample size summary report. Default isTrue.
Returns¶
- pd.DataFrame
The dataframe with a single row and a number of columns equal to the number of model variables. The unique index of the dataframe is
Effective Sample Size.
Raises¶
- TypeError
If
posteriorsis not adict,if a posterior sample is not a
numpy.ndarray,if
print_summaryis not abool.
- KeyError
If
posteriorsdoes not containinterceptkey.- ValueError
If a posterior sample is an empty
numpy.ndarray.
See Also¶
baypy.diagnostics.functions.autocorrelation_plot()baypy.diagnostics.functions.autocorrelation_summary()Notes¶
The effective number of sample could be theoretically equal to the number of iterations in case of no auto-correlation of the Markov chain. The greater the auto-correlation of the Markov chain, the smaller the effective sample size of the posterior.