GVAR.solve#
- GVAR.solve()[source]#
Close the system and return the global result.
Each unit is read through its
to_varx()into the levels form it implies, the link matrices and the stacked \(G_0, G_l\) are built and \(G_0\) inverted bysolve_global, the unit residuals are aligned on the common sample and rotated through \(G_0^{-1}\), and the record is assembled. The global order is the deepest lag any unit uses, the trend label is read off the widest deterministic block, and the innovation covariance is divided by the common sample less the widest unit design.- Return type:
- Returns:
A
GVARResult.- Raises:
DimensionError – If the units do not partition the global columns.
NumericalError – If the contemporaneous linkage is singular.
Example
A levels unit of order two linked to an error-correction unit of order one; the global system takes the deeper order, the common sample is the shorter residual series, and the fitted identity holds exactly:
>>> import numpy as np >>> from cultivars.multivariate.reduced_form.vector_autoregression import VARX >>> from cultivars.multivariate.reduced_form.error_correction import VECMX >>> rng = np.random.default_rng(0) >>> world, sat = np.zeros(400), np.zeros(400) >>> for t in range(1, 400): ... world[t] = world[t - 1] + rng.standard_normal() ... gap = world[t - 1] - sat[t - 1] ... sat[t] = sat[t - 1] + 0.3 * gap + 0.5 * rng.standard_normal() >>> units = [ ... VARX(world[:, None], sat[:, None], order=2, exog_order=1).fit(), ... VECMX(sat[:, None], world[:, None], order=1, rank=1).fit(), ... ] >>> swap = np.array([[0.0, 1.0], [1.0, 0.0]]) >>> res = GVAR(units, swap, variable_labels=["p", "p"]).solve() >>> res.order, res.nobs, res.trend, res.unit_names (2, 398, 'c', ('unit1', 'unit2')) >>> x, (first, second) = res.endog, res.coefficients >>> fitted = x[1:-1] @ first.T + x[:-2] @ second.T + res.deterministic[0] >>> bool(np.allclose(x[2:], fitted + res.resid)) True