SV.fit#
- SV.fit(*, method='qml', n_particles=500, seed=None)[source]#
Point-estimate the model.
- Parameters:
method (
str) –"qml"for Harvey-Ruiz-Shephard quasi-maximum likelihood on the linearized model,"particle"for simulated maximum likelihood on the particle filter’s estimate under common random numbers (Nelder-Mead from the QML start).n_particles (
int) – Particles per evaluation under"particle", at least 50.
- Return type:
- Returns:
The fitted
SVResult.- Raises:
SpecificationError – If the method is unknown, or
n_particlesis below 50 under"particle".
Example
QML is the fast estimator; the particle estimator starts from it and is far slower, so it is not run here:
>>> import numpy as np >>> from cultivars.engine._internals._simulators import _simulate_stochastic_volatility >>> rng = np.random.default_rng(0) >>> y, _ = _simulate_stochastic_volatility( ... 300, mu=-1.0, phi=0.95, sigma2=0.05, mean=0.0, rng=rng ... ) >>> res = SV(y, mean="zero").fit() >>> res.method, bool(0.85 < res.phi < 1.0) ('qml', True) >>> SV(y).fit(method="mle") Traceback (most recent call last): ... cultivars.exceptions.SpecificationError: method must be 'qml' or 'particle'; got 'mle'.