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 ofidataimplies.- Parameters:
- idata
arviz.InferenceData Inference data whose
posteriorgroup holds draws of the model parameters.- n_lags
int Number of non-zero lags to compute; the returned
lagdimension hasn_lags + 1entries. 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_step
int 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_kwargs
dict, optional Passed through to
pymc.compute_deterministics().
- idata
- Returns:
DataArrayAutocorrelation matrices with dimensions
(chain, draw, lag, state, state_aux), where the state dimensions are the observed states whenobservedis True and the latent states otherwise.