## 3 Generalized Causality Algorithm
### Simulation Study  
In this section, we perform a simulation study with synthetic data to validate the generalized causality algorithm. Following [9], two stationary time series \(X=(X(t))_{t\in\{1,\ldots,N\}}\) and \(Y=(Y(t))_{t\in\{1,\ldots,N\}}\) are generated, whereby \(X\) leads \(Y\)--without loss of generality \(Y\) can also lead \(X\). In contrast to the existing literature, our algorithm is able to handle time-varying lead-lag structures resulting in more flexible and realistic scenarios. From a mathematical point of view  
For a better understanding of the algorithm the following example is presented. First, we simulate the processes \(X\) and \(Y\) with three different lead-lag phases, i.e., \(r=3\). Specifically, the following subsets are constructed:  
* The first phase (\(Z_{t}=1\)) contains 100 data points (\(N_{1}=100\)) where \(X\) leads \(Y\) by 1 lag (\(l_{1}=1\)) with a \"strength\" of \(a_{1}=0.8\). * The second phase (\(Z_{t}=2\)) contains 100 data points (\(N_{2}=100\)) where \(X\) leads \(Y\) by 3 lags (\(l_{2}=3\)) with a \"strength\" of \(a_{2}=0.8\). * The third phase (\(Z_{t}=3\)) contains 100 data points (\(N_{3}=100\)) where \(X\) leads \(Y\) by 5 lags (\(l_{3}=5\)) with a \"strength\" of \(a_{3}=0.8\). Summarizing, we create the stochastic processes \(X\) and \(Y\) of length \(N=N_{1}+N_{2}+N_{3}=300\) with three different lead-lag structures. As already mentioned, our algorithm would be able to handle different lengths, but we renounce it for reasons of consistency with the existing literature and better comprehensibility. The other parameter values are set identical to [9], who assumes a constant lead lag structure--we set \(b=0.7\), \(\sigma_{X}^{2}=1\), and \(f=1\). Furthermore, we define the local cost measure \(c\) as the absolute difference between \(x(n_{i})\) and \(y(m_{i})\) (\(i\in\{1,\ldots,I\}\)), see Equation (3). Figure 3 represents the corresponding simulated time series \(X\) and \(Y\). In order to obtain reasonable results, \(X\) and \(Y\) are standardized, i.e., our time series start at value 1 and develop on the basis of the corresponding growth rates. We recognize that no lead-lag structures are visible to the naked eye. Furthermore, applying the classical lagged-cross correlation does not make sense for two reasons. First, it would be naive to associate the tiny peaks of the correlation function at 1, 3, and 5 to identify lags between the two time series. Second, finding structural breaks is impossible because the lagged-cross correlations are estimated over the whole time interval. Figure 4 shows the results of applying our generalized causality algorithm. Specifically, we illustrate the local costs and the identified optimal causal path. Similar to Figure 1, the optimal causal path runs along a \"valley\" of low cost (light colors) and prevents \"mountains\" of high cost (dark color). On the x-axis, there are two identified structural breaks (large bars) with the corresponding 95 percent confidence interval (small bars). We observe that the optimal causal path represents a diagonal shifted by the number of lags \(l_{1}=1\), \(l_{2}=3\), and \(l_{3}=5\)--a few outliers are explained by noise variations in the simulated time series. Figure 3: Simulation of time series \(x\) and \(y\) with \(r=3\) regimes and lead–lag relations \(l_{1}=1\), \(l_{2}=3\), and \(l_{3}=5\). Therefore, \(y\) follows \(x\) by 1 lag in the first phase, 3 lags in the second phase, and 5 lags in the third phase. Figure 5 depicts the detailed development of our estimated lags, i.e., the difference between the index of \(x\) and the index of \(y\). We note that the length of the optimal causal path is greater than \(N=300\) (see Section 2). The first regime possesses a length of around 110 and shows a constant course of 1, i.e., \(x\) leads \(y\) by 1 lag. The first structural break initiates the second sub-period, which exhibits a lag of 3 and is terminated with the second regime-switch. The third phase shows a time delay of 5 with a short-term outlier to lag 6.