pyhctsa.operations.stationarity.drifting_mean_cusum

pyhctsa.operations.stationarity.drifting_mean_cusum(y)

Drift in the mean, via a cumulative-sum (CUSUM) test.

Tests whether the mean of the (z-scored) time series is stationary using CUSUM/bridge statistics on its cumulative sum, cumsum(y). Under a stationary mean the cumulative sum grows ~linearly; systematic curvature, or a localized departure from that line, indicates drift (cf. Inclan-Tiao’s test for a change point in variance, and trend(), which fits a line to y itself). The statistics that merely re-express the linear trend of y (meanYC, gradient, intercept, meanYC12, meanYC22, stdBridge) are not output.

Parameters:
y : array-like

The input time series (assumed z-scored).

Returns:

Statistics on yC = cumsum(y), or NaN if y has fewer than 20 samples:

  • ’maxBridge’: the largest absolute deviation of yC from the straight line joining 0 to its final value (the ‘bridge’), divided by std(y)*sqrt(N),

  • ’posMaxBridge’: the position (from 0 to 1) of that largest deviation,

  • ’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