PanelVARResult._unit_index#

PanelVARResult._unit_index(unit)[source]#

Position of a unit, or a failure naming the ones that exist.

Parameters:

unit (str) – One of unit_names.

Return type:

int

Returns:

The unit’s index into unit_names, unit_lengths and _sample_blocks.

Raises:

SpecificationError – If the unit is not one of unit_names.

Example

>>> import numpy as np
>>> panel = np.random.default_rng(0).standard_normal((3, 40, 2))
>>> res = PanelVAR(panel, order=1, unit_names=["a", "b", "c"]).fit()
>>> res._unit_index("b")
1
>>> res._unit_index("d")
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: unknown unit 'd'; expected one of ('a', ...