QVAR.fit#

QVAR.fit(*, quantiles=(0.1, 0.5, 0.9))[source]#

Estimate every equation at every requested level.

The levels are sorted ascending on the result whatever order they were given in; each is solved independently, so adding a level does not change the others.

Parameters:

quantiles (Sequence[float]) – Distinct levels, each strictly inside (0, 1). The default brackets the distribution the way the growth-at-risk literature reads it: both tails and the median.

Return type:

QVARResult

Returns:

The fitted QVARResult.

Raises:

Example

>>> import numpy as np
>>> y = np.random.default_rng(0).standard_normal((150, 2))
>>> model = QVAR(y, order=1)
>>> model.fit().quantiles
(0.1, 0.5, 0.9)
>>> model.fit(quantiles=(0.9, 0.1)).quantiles
(0.1, 0.9)
>>> single = model.fit(quantiles=(0.5,))
>>> bool(np.allclose(single.coefficients(0.5), model.fit().coefficients(0.5)))
True
>>> model.fit(quantiles=())
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: quantiles must name at least one level.
>>> model.fit(quantiles=(0.5, 0.5))
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: quantiles must be distinct; got (0.5, 0.5).
>>> model.fit(quantiles=(1.0,))
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: quantiles must lie in (0.0, 1.0); got 1.0.