## 3 Materials and Methods
### Bubble Model Training Strategy  
Equation (1) of Section 2.4 gives us clues about the features we can consider to feed the learning process. First, we have a cumulative process of positive price variations over time, and second, an acceleration of these variations as the critical time approaches. To better understand the features, let us consider the trajectory of the S&P500 from 1982 to 2024. We compute two features: first, the long-range \(\delta\) returns  
\[r_{t}^{\delta}=\frac{r_{t}-r_{t-\delta}}{r_{t}}, \tag{11}\]  
where \(r_{t}\) is the long-range return of \(\delta\) days at time \(t\). Second, the slope is calculated as follows:  
\[s_{t}^{\delta}=\frac{p_{t}-p_{t-\delta}}{\delta}. \tag{12}\]  
Now that we have defined the long-range return and the slope, we will show an example where we have calculated the feature every \(\delta=500\) days, as shown in Figure 5. From the dynamics of the slopes and the long-range accumulated returns, we see that as the value of the index increases at a higher rate during accumulating profits, the slopes begin to diverge from the accumulated returns. Both seem to meet again in the middle of the instability zone, making the divergence virtually null. At the end of the sharp falls and the beginning of the recovery, we see that the divergence begins to increase in positive terms (\(r_{t}^{\delta}>s_{t}^{\delta}\)), and this condition is maintained until another cycle of instability is repeated again. This is best seen in the 2000 and 2008 crises (bands b and c in Figure 5). The divergence is close to zero when the market has bottomed out. In the 2022 crisis, amid the index decline, a trend of convergence of the cumulative returns and slopes can also be observed, making the divergence very small. Interestingly, in recent years, there is a sustained increase in divergence in negative terms (\(r_{t}<s_{t}\)), where the slopes are greater than the cumulative returns. Of course, this does not necessarily indicate a crisis, so it is necessary to consider measures of volatility, short-term returns, and slopes with other \(\delta\) ranges. Similar graphs, but based on simulations, depicting periods of normality (simulated with Geometric Brownian Motion) followed by a gradual increase in the index following the LPTLS model, can be seen in Appendix C. In these simulations, we can see that divergence in bubble periods tends to be exacerbated. Naturally, this behavior does not consider the inherent complexity of the real S&P500 index. However, it is necessary to understand better how these predictors act in the presence of bubbles. All the information comes from the stock or index prices. Let us call \(p_{t}\) the price in period \(t\). Let us consider the price change as \(r_{t}=p_{t}-p_{t-1}\). Volatility, on the other hand, is the price variation occurring on a transaction day. Consider the volatility at day \(t\) as \(v_{t}=\frac{p_{\max}}{p_{\min}}\), where \(p_{\max}\) and \(p_{\min}\) are the maximum and minimum price occurred in the period. Thus, \(v_{t}\geq 1\). When \(v_{t}\) is close to 1, it indicates slight price fluctuation and conversely, when it is greater than 1, it indicates high intra-day fluctuation. So, the GGRBM is trained with continuous values of volatility \(v_{t}\), continuous daily returns, using \(k\) lags, long-range returns \(r_{t}\), and slopes \(s_{t}\). As with any classification problem, an ideally balanced set of samples from the positive and negative classes is necessary to train a supervised model. We are not in a situation where financial bubbles are abundant, so no matter how we define a sample as belonging to a bubble, there will always be a much smaller number of such samples than non-bubbles. In our approach, we define a bubble sample as any observation occurring within a fixed window of \(r\) trading days preceding the critical point \(t_{c}\), which corresponds to the peak price before a major drop or crash.