FunctionalCoefficientVAR.fit#
- FunctionalCoefficientVAR.fit(*, bandwidth=None, n_grid=51, trim=0.05)[source]#
Estimate the coefficient curves by local-linear kernel regression.
The curves are evaluated on
n_gridequally spaced points between thetrimand1 - trimquantiles of the state; the cross-validation criterion, when it runs, is scored on the observations inside that range only.- Parameters:
bandwidth (
float|None) – Kernel bandwidth in the state variable’s units, orNoneto select by leave-one-out cross-validation on a grid around the Silverman-scaled rule of thumb.n_grid (
int) – Evaluation points for the reported curves.trim (
float) – Quantile trimmed from each end of the state range before the curve grid is laid down.
- Return type:
- Returns:
The fitted
FunctionalCoefficientVARResult.- Raises:
SpecificationError – If a stated bandwidth is not positive,
n_gridis below 2, ortrimis outside[0, 0.5).NumericalError – If no bandwidth identifies every local system.
Example
>>> import numpy as np >>> y = np.random.default_rng(0).standard_normal((150, 2)) >>> model = FunctionalCoefficientVAR(y, order=1, transition_variable="y1") >>> res = model.fit(bandwidth=1.0, n_grid=11, trim=0.1) >>> res.grid.shape, res.bandwidth, res.bandwidth_searched ((11,), 1.0, False) >>> model.fit(bandwidth=-1.0) Traceback (most recent call last): cultivars.exceptions.SpecificationError: bandwidth must be positive; got -1.0. >>> model.fit(bandwidth=0.05) Traceback (most recent call last): cultivars.exceptions.NumericalError: the local system at state value ... is ...