GVARResult._unit_index#
- GVARResult._unit_index(unit)[source]#
Position of a unit, or a failure naming the ones that exist.
- Parameters:
unit (
str) – One ofunit_names.- Return type:
- Returns:
The unit’s index into
unit_names,unit_sizesandunits.- Raises:
SpecificationError – If the unit is not one of
unit_names.
Example
>>> import numpy as np >>> from cultivars.multivariate.reduced_form.vector_autoregression import VARX >>> y = np.random.default_rng(0).standard_normal((200, 2)) >>> units = [VARX(y[:, [i]], y[:, [1 - i]], order=1).fit() for i in (0, 1)] >>> swap = np.array([[0.0, 1.0], [1.0, 0.0]]) >>> names = ("us", "eu") >>> res = GVAR(units, swap, variable_labels=["p", "p"], unit_names=names).solve() >>> res._unit_index("eu") 1 >>> res._unit_index("uk") Traceback (most recent call last): cultivars.exceptions.SpecificationError: unknown unit 'uk'; expected one of ('us', ...