LongMemorySVResult.autocorrelation#
- LongMemorySVResult.autocorrelation(lags=50)[source]#
Implied autocorrelation of the log variance at lags
0..lags.The ARFIMA(1, d, 0) autocorrelation, computed from the spectrum by Fourier inversion on a fine grid; its hyperbolic tail is the model’s signature and the thing to hold against the sample autocorrelation of
log((y - c)**2)after the white-noise floor is netted out.- Parameters:
lags (
int) – Largest lag, at least 1.- Return type:
- Returns:
An array of shape
(lags + 1,)with1.0first.- Raises:
SpecificationError – If
lagsis not positive.
Example
>>> 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() >>> acf = res.autocorrelation(10) >>> acf.shape, float(acf[0]), bool(np.all(np.diff(acf) < 0.0)) ((11,), 1.0, True) >>> acf[[1, 5, 10]].round(2).tolist() [0.62, 0.42, 0.35] >>> res.autocorrelation(0) Traceback (most recent call last): cultivars.exceptions.SpecificationError: lags must be at least 1; got 0.