Skip to main content
. 2022 Sep 12;22(18):6884. doi: 10.3390/s22186884
Algorithm 1 Main methodology to identify time-varying lead-lag relationships.
 procedureMain step 1: Compute multi-dimensional DTW alignment (Input:
 two stationary univariate time series).
  Step 1 Z-normalize both time series.
  Step 2 Convert univariate time series to multi-dimensional descriptor series
        as in shapeDTW [4].
    Step 2.1 Pad beginning and ending of time series by repeating the first and last
           element (l12) times, respectively.
    Step 2.2 At each original index i, extract the subsequence of length l centred
           at i.
    Step 2.3 Take each subsequence as vector for describing the respective index.
    Step 2.4 Optionally concatenate subsequence with its first difference to
          include shape characteristics invariant to the level of the values.
  Step 3 Z-normalize each dimension to allow for equal contribution as in
       Shokoohi-Yekta et al. [15].
  Step 4 Calculate the local cost matrix using dependent multi-dimensional DTW.
  Step 5 Perform DTW on the local cost matrix, while optionally relaxing the
        boundary condition.
  Output DTW distance, optimal warping path, accumulated cost matrix,
        local cost matrix, optimal start- and endpoint.
end procedure
procedure Main step 2: Extract lead-lag relationship (Input: optimal warping path, optimal start- and endpoint).
  Assumption Relationship of the form Y(j)=c+a·X(jτ(j))+η,
           withηN(0,ση) in similar spirit to Sornette and Zhou [38].
  Step 1 If relaxed boundary condition, transfer optimal warping path to
       indices of original local cost matrix.
  Step 2 Subtract matched indices of the optimal warping path.
  Step 3 For each index of Y, take a value that comes last in the optimal warping path.
   Output Identified lead-lag relationship.
end procedure