autocorrelation_summary

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.ndarray with 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 True prints the autocorrelation summary report. Default is True.

Returns

pd.DataFrame

The dataframe with a number of row equal to the number of element in lags and a number of columns equal to the number of model variables. Lags are reported in dataframe index.

Raises

TypeError
  • If posteriors is not a dict,

  • if a posterior sample is not a numpy.ndarray,

  • if lags is not a list,

  • if lags does not contain only int,

  • if print_summary is not a bool.

KeyError

If posteriors does not contain intercept key.

ValueError
  • If a posterior sample is an empty numpy.ndarray,

  • if lags is an empty list,

  • if a value in lags is a negative int.

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.