FunctionalCoefficientVAR#

class cultivars.multivariate.nonlinear.functional_coefficient.FunctionalCoefficientVAR(endog, *, order, transition_variable, delay=1, trend='c', names=None)[source]

Bases: _FunctionalCoefficientVectorAutoRegressionModel[FunctionalCoefficientVARResult]

Functional-coefficient VAR, after Cai, Fan and Yao: local-linear estimation.

Every coefficient is an unknown smooth function of an observable state – a named variable’s own lag, or an external series – estimated with no assumption on its shape beyond smoothness. At each evaluation point one Epanechnikov-weighted least squares on the augmented design \([x_t,\ x_t (z_t - u)]\) delivers the local level and slope of every coefficient, all equations sharing the weights. The bandwidth is the one tuning constant; left unstated, it is chosen by exact leave-one-out cross-validation over a geometric grid around the Silverman rule \(2.34\,\hat\sigma_z\, n^{-1/5}\). There is no delay search, because the bandwidth is this model’s tuning axis and searching both would let the smoother trade one against the other invisibly.

Variables:
  • _endog – The observed panel, from the base model.

  • _order – The autoregressive order p, from the base model.

  • _trend – The deterministic specification, from the base model.

  • _names – The variable labels, from the base model.

  • _delays – The single delay, as a one-element tuple, from the observed-regime base.

  • _threshold_name – The state’s label, from the observed-regime base.

  • _transition_series – The aligned state series, from the observed-regime base.

Parameters:
  • endog (ArrayLike) – The observed panel, shape (nobs, k).

  • order (int) – Autoregressive order, at least one.

  • transition_variable (str | ArrayLike) – A variable name from names (the state is that variable’s own lag) or an aligned external series.

  • delay (int) – Delay of the state variable. Defaults to one.

  • trend (Literal['n', 'c', 'ct']) – Deterministic terms.

  • names (Sequence[str] | None) – One label per variable. Defaults to y1 ... yk.

Raises:
  • SpecificationError – If the specification is malformed.

  • DimensionError – If the effective sample is shorter than six times the per-window coefficient count, which local-linear estimation needs.

See also

References

Cai, Z., Fan, J., & Yao, Q. (2000). Functional-coefficient regression models for nonlinear time series. Journal of the American Statistical Association, 95(451), 941-956.

Chen, R., & Tsay, R. S. (1993). Functional-coefficient autoregressive models. Journal of the American Statistical Association, 88(421), 298-308.

Hastie, T., & Tibshirani, R. (1993). Varying-coefficient models. Journal of the Royal Statistical Society, Series B, 55(4), 757-796.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.zeros((250, 2))
>>> for t in range(1, 250):
...     a = 0.8 * np.tanh(y[t - 1, 0])
...     y[t, 0] = a * y[t - 1, 0] + 0.5 * rng.standard_normal()
...     y[t, 1] = 0.4 * y[t - 1, 1] + 0.5 * rng.standard_normal()
>>> model = FunctionalCoefficientVAR(y, order=1, transition_variable="y1")
>>> res = model.fit(bandwidth=1.2, n_grid=21)
>>> res.coefficient_curve("y1", "y1.L1").shape
(21, 3)
>>> res.irf(4, u=0.0).shape
(5, 2, 2)
>>> searched = model.fit(n_grid=21)
>>> searched.bandwidth_searched, bool(0.5 < searched.bandwidth < 2.5)
(True, True)
>>> cycle = np.sin(np.arange(250) / 20)
>>> external = FunctionalCoefficientVAR(y, order=1, transition_variable=cycle)
>>> external.fit(bandwidth=0.5, n_grid=11).state_name
'external'