pyhctsa.operations.stationarity.drifting_auto_corr¶
-
pyhctsa.operations.stationarity.drifting_auto_corr(y, tau=
1, what_product='ac')¶ Drift in a lag-tau (auto)correlation via a cumulative-sum test.
Forms a lag-tau cross-term product series
p_tand tests whether its mean (i.e., the corresponding linear or nonlinear correlation statistic) is stationary, via CUSUM/bridge statistics oncumsum(p)(seedrifting_mean_cusum()). Under stationaritycumsum(p)grows ~linearly; systematic curvature or a localized departure from that line indicates that the correlation structure, not just the mean or variance ofyitself, is drifting over the course of the time series. This is a CUSUM-style stationarity test (cf. Inclan-Tiao’s test for a change point in variance) applied to a lag-product series rather than toyitself, mirroring whattrend()does fory’s own cumsum.- Parameters:¶
- y : array-like¶
The input time series (assumed z-scored).
- tau : int, optional¶
The lag defining the cross term. Default is 1.
- what_product : {'ac', 'forward', 'backward', 'asymmetry'}, optional¶
Which cross term
p_tto test for drift:’ac’:
y(t) * y(t+tau), the linear autocorrelation,’forward’:
y(t) * y(t+tau)^2, nonlinear/asymmetric (does the signed value now predict the squared, energy-like value later? cf.autocorr_x2()),’backward’:
y(t)^2 * y(t+tau), the other direction (does the squared value now predict the signed value later?),’asymmetry’:
y(t) * y(t+tau) * (y(t+tau) - y(t))= forward - backward, the leverage/time-irreversibility signature itself (it vanishes in expectation for time-reversible linear processes); tests whether that asymmetry, not just its forward or backward half, is drifting over the time series.
Default is
'ac'.
- Returns:¶
Statistics on the cumulative sum
yC = cumsum(p)(phas N - tau values), or NaN if there are fewer than 20 products, ortau >= N - 1:’meanYC’: the mean of
yC,’gradient’, ‘intercept’: slope and intercept of an ordinary least-squares line fit to
yCagainst time,’meanYC12’, ‘meanYC22’: the mean of
yCin the first and second half of the series,’maxBridge’: the largest absolute deviation of
yCfrom the straight line joining 0 to its final value (the ‘bridge’), divided bystd(p)*sqrt(N-tau),’posMaxBridge’: the position (from 0 to 1) of that largest deviation,
’stdBridge’: the standard deviation of the bridge,
’gradientDiffSE’: the difference between the OLS and a robust (bisquare) slope fit to
yC, in standard errors of the robust slope,’residStdRatio’: the standard deviation of the OLS residuals over that of the robust-fit residuals,
’varRatioTrend’: the Kendall rank correlation between time and the log of the squared bridge divided by its Brownian-bridge null variance: whether the bridge wanders more (or less) later in the series than expected under stationarity.
- Return type:¶
dict