LongMemorySVResult#

class cultivars.multivariate.structural.stochastic_volatility.LongMemorySVResult(*, endog, mean_spec, mean, mu, d, sigma2, phi, short_memory, llf, nobs, n_params, n_frequencies, log_variance, log_variance_std)[source]#

A Whittle-estimated long-memory stochastic-volatility model.

The fitted law is

\[y_t = c + e^{h_t/2} \epsilon_t, \qquad h_t = \mu + v_t, \qquad (1 - \phi L)(1 - L)^d v_t = \eta_t,\]

estimated on the linearization \(\log (y_t - c)^2 = \mu + \mathbb{E}\log\epsilon_t^2 + v_t + \xi_t\) by maximizing the Whittle criterion over the positive Fourier frequencies, where the spectrum of the log-squared data is the ARFIMA(1, d, 0) spectrum plus the \(\pi^2/2\) white-noise floor of \(\xi_t\). The record carries the estimate, the criterion, and the log-variance path from the spectral smoother with its one stationary error band.

Note

llf is a quasi-likelihood: comparable with other Whittle fits through compare() and likelihood_ratio_test(), not with a Kalman or particle likelihood of the same data. d and phi compete for the same persistence – with short_memory the AR(1) can absorb most of the memory and push d toward zero – and a small d against the measurement floor is weakly identified; the summary says both.

Variables:
  • endog – The observed series.

  • mean_spec – "constant" or "zero".

  • mean – The observation mean c.

  • mu – Level of the log variance.

  • d – Fractional differencing order of the log variance.

  • sigma2 – Innovation variance of the fractional noise.

  • phi – Short-memory AR(1) coefficient of the log variance; 0.0 when the law is pure fractional noise.

  • short_memory – Whether phi was estimated.

  • llf – The Whittle criterion at the optimum, read as a log-likelihood: the frequency-domain quasi-likelihood of the linearized model. Comparable only with other Whittle fits.

  • nobs – Observations.

  • n_params – Free parameters.

  • n_frequencies – Fourier ordinates the criterion summed over.

  • log_variance – Smoothed log-variance path, (n,), from the spectral smoother.

  • log_variance_std – The smoother’s stationary root mean squared error, repeated (n,) times.

See also

References

Breidt, F. J., Crato, N., & de Lima, P. (1998). The detection and estimation of long memory in stochastic volatility. Journal of Econometrics, 83(1-2), 325-348.

Harvey, A. C., Ruiz, E., & Shephard, N. (1994). Multivariate stochastic variance models. Review of Economic Studies, 61(2), 247-264.

Example

Fractional noise with d = 0.4 in the log variance. The Whittle fit recovers the order and the innovation variance, the smoothed path tracks the truth, and the implied autocorrelation decays hyperbolically:

>>> import numpy as np
>>> from cultivars.engine._core._transforms import _fractional_difference_weights
>>> rng = np.random.default_rng(0)
>>> n, burn = 1500, 2000
>>> eta = 0.5 * rng.standard_normal(n + burn)
>>> weights = _fractional_difference_weights(-0.4, n + burn)
>>> v = np.convolve(eta, weights)[burn : n + burn]
>>> y = np.exp((-1.0 + v) / 2) * rng.standard_normal(n)
>>> res = LongMemorySV(y, mean="zero").fit()
>>> round(res.d, 2), round(res.sigma2, 2), res.phi, res.short_memory
(0.39, 0.1, 0.0, False)
>>> res.nobs, res.n_params, res.n_frequencies, res.at_boundary
(1500, 2.0, 750, False)
>>> bool(np.corrcoef(res.log_variance, -1.0 + v)[0, 1] > 0.4)
True
>>> acf = res.autocorrelation(200)
>>> bool(abs(acf[200] / acf[100] - 2 ** (2 * res.d - 1)) < 0.1)
True

Attributes#

endog

The observed series, (n,).

mean_spec

"constant" when the sample mean was removed, "zero" when fixed at zero.

mean

the sample mean, or 0.0.

mu

Level of the log variance.

d

Fractional differencing order, searched over |d| < 0.5.

sigma2

Innovation variance of the fractional noise.

phi

Short-memory AR(1) coefficient of the log variance; 0.0 unless estimated.

short_memory

Whether phi was estimated.

llf

The Whittle quasi-likelihood at the optimum; comparable only with Whittle fits.

nobs

Observations.

n_params

mu, d, sigma2, plus phi and mean when estimated.

n_frequencies

Positive Fourier ordinates the criterion summed over, n // 2.

log_variance

The (n,) spectrally smoothed log-variance path.

log_variance_std

The smoother's stationary root mean squared error, repeated (n,) times.

at_boundary

Whether d sits at the stationarity boundary of the search.

information_criteria

AIC, BIC, and HQIC derived from the likelihood and parameter count.

volatility

Smoothed volatility exp(h_t / 2), (n,).

fittedvalues

resid

Methods#

autocorrelation([lags])

Implied autocorrelation of the log variance at lags 0..lags.

compare(*others[, criterion])

Rank this result against others by an information criterion.

likelihood_ratio_test(unrestricted)

Test this result as the restricted model against a nesting one.

quasi_state_space([truncation])

The linearized model as a truncated AR(inf) linear-Gaussian state space.

summary()

The estimation summary, renderable as text, HTML, or a dataframe.

to_dict()

The aligned per-observation outputs as plain numpy arrays.

to_pandas(*[, index])

The aligned per-observation outputs as a pandas.DataFrame.

to_polars()

The aligned per-observation outputs as a polars.DataFrame.

volatility_bands([level])

Smoother bands on the volatility at a Gaussian coverage level.