pyhctsa.operations.correlation.residual_autocorr_scan¶
-
pyhctsa.operations.correlation.residual_autocorr_scan(y, max_lag=
300, max_ar_order=10)¶ Long-lag dependence: the largest autocorrelation of the AR residuals over a wide range of lags.
A dependence at a single long lag (a seasonal or delayed-feedback term, say) is invisible to the autocorrelation at short lags and is diluted in summaries of the whole autocorrelation function. This function removes the short-range linear structure first and then scans the residual autocorrelation function for its largest value, following the residual portmanteau tests of Box and Pierce [1] and Ljung and Box [2], and of McLeod and Li [3] for the squared residuals.
The series is prewhitened by an autoregressive model whose order p (at most
max_ar_order) is chosen by AIC [4], with Yule-Walker coefficients from the Levinson-Durbin recursion [5]. Let \(r_k\) be the sample autocorrelation of the \(m = N - p\) residuals at lag \(k\), for \(k = 1, ..., K\), with \(K = \min(\)max_lag\(, \lfloor m/4 \rfloor)\). Each is standardised by its standard error under whiteness, \(z_k = r_k \sqrt{m(m+2)/(m-k)}\), and the outputs are the largest \(|z_k|\) and its lag, and the Ljung-Box statistic \(Q = \sum_k z_k^2\) as an approximate standard normal score, \((Q - d)/\sqrt{2d}\), with \(d = K - p\) degrees of freedom (at least 1). The same statistics of the squared residuals (with \(d = K\)) respond to dependence in amplitude (volatility clustering, or a lagged dependence of the size of fluctuations) rather than in sign.- Parameters:¶
- Returns:¶
‘max_z’: the largest \(|z_k|\) of the residuals.
’peak_lag’: the lag \(k\) at which it occurs.
’lb_z’: the Ljung-Box statistic of the residuals as a z-score.
’sq_max_z’: the largest \(|z_k|\) of the squared residuals.
’sq_lb_z’: the McLeod-Li statistic (Ljung-Box of the squared residuals) as a z-score.
All NaN if the series is constant or has fewer than 8 residuals; the squared-residual fields are NaN if the squared residuals are constant.
- Return type:¶
dict
References