BVARResult._stack_of#

BVARResult._stack_of(beta)[source]#

Slice one (w, k) coefficient matrix into its (p, k, k) lag stack.

The inverse of the design layout: rows n_det + (l - 1) * k through n_det + l * k - 1 of beta are the lag-l block, and each is transposed so that slice l - 1 is \(A_l\) with [i, j] the response of equation i to variable j. Applied to beta_mean it reproduces coefficients; applied to a draw it gives that draw’s lag stack, which is what _irf_draws(), forecast_paths(), and stable_share hand to companion_matrix() or iterate directly. The deterministic rows are dropped, not returned; callers that need them slice beta[:n_det] themselves.

Parameters:

beta (NDArray[double]) – A (w, k) coefficient matrix in design-row order – beta_mean or one slice of beta_draws.

Return type:

NDArray[double]

Returns:

A (p, k, k) array; (0, k, k) when order is zero.

Example

>>> import numpy as np
>>> from cultivars.multivariate.large_dim.bayesian import BVAR
>>> y = np.random.default_rng(0).standard_normal((60, 3))
>>> res = BVAR(y, order=2, trend="ct").fit(n_draws=10, seed=0)
>>> np.allclose(res._stack_of(res.beta_mean), res.coefficients)
True
>>> res._stack_of(res.beta_draws[0]).shape
(2, 3, 3)