gEconpy.model.statespace.DSGEStateSpace.sample_autocorrelation_matrices#

DSGEStateSpace.sample_autocorrelation_matrices(idata, n_lags=10, observed=False, lag_step=1, compile_kwargs=None)#

Posterior distribution of the model-implied autocorrelation matrices.

For each posterior draw the stationary state covariance \(\Sigma\) is found from the discrete Lyapunov equation \(\Sigma = T \Sigma T^\top + R Q R^\top\), and the autocorrelation at lag \(k\) is \(T^{k \cdot \texttt{lag\_step}} \Sigma\), normalized by the state standard deviations. The whole calculation is built as a single PyTensor graph and evaluated across every draw at once with pymc.compute_deterministics(), so there is no Python loop over samples.

The model must already have been built with build_statespace_graph(), which the presence of idata implies.

Parameters:
idataarviz.InferenceData

Inference data whose posterior group holds draws of the model parameters.

n_lagsint

Number of non-zero lags to compute; the returned lag dimension has n_lags + 1 entries. Default 10.

observedbool

Return the autocorrelation of the observed series – the design matrix applied to the state, with measurement error included in the lag-0 variance – instead of the latent states. Default False.

lag_stepint

Spacing between lags, in model periods. Use 1 for the model’s native frequency. For an observable that is a temporal aggregate (for example an annual series from a quarterly model), set this to the aggregation period so successive lags are one observation apart. Default 1.

compile_kwargsdict, optional

Passed through to pymc.compute_deterministics().

Returns:
DataArray

Autocorrelation matrices with dimensions (chain, draw, lag, state, state_aux), where the state dimensions are the observed states when observed is True and the latent states otherwise.