## 4 Results
### Instability Detection  
For the instability detection model, we generate sequences of non-stable and unstable samples with a duration of 100 days, as described in detail in Appendix B. We generate 32500 discretized volatility and return strips, which will consequently be the input vectors to the BBRBM. We use 80% of these as training and the remaining 20% as tests. This is conducted using lags of \(k=3\), \(k=8\), and \(k=16\) days. The BBRBM is trained with a learning rate of 0.01, a constant decay of 0.01, 500 epochs, and a batch size of 128 samples. We empirically test different configurations of these parameters, monitoring the evolution and ensuring a clear convergence of the log-likelihood function [77]. For the PCD, we use only \(n=1\) step to run the Markov chain. In choosing the number of hidden units, we prioritize a richer and more detailed embedding, so we selected 9, 24, and 48 hidden units from the BBRBM for the cases of \(k=3\), \(k=8\), and \(k=16\) lags, respectively. Since we use synthetic samples, we do not risk overfitting the empirical data. The ANN is trained with the BBRBM hidden unit values obtained when the BBRBM volatility and synthetic return slices (not used in the BBRBM training) are presented to the BBRBM input layer. A hyperparameter grid search is used to select the best design combination. In particular, we test with different numbers of units of the ANN hidden layer, the optimizer (Adaptive Estimation of first-order and second-order moments, ADAM, or Stochastic Gradient Descent, SGD), the learning rate, and batch size. The parameters selected are those for which a better AUC is achieved on a test dataset. For \(k=3\), the number of hidden units is 12, SGD, learning rate of 0.001, and batch size of 12. For \(k=8\), the number of hidden units is 32, ADAM, learning rate of 0.001, and batch size of 8. For \(k=16\), the number of hidden units is 24, SGD, learning rate of 0.001, and batch size of 8. Figure 6 (Left) shows the performance results of different ANNs trained with the values of the BBRBM hidden units with different numbers of lags. It is worth considering that the classification is achieved only by detecting the patterns of zeros and ones in the volatility and return strips without specifying any time dependence in advance. This is as if the ANN had to recognize images of one type or another. This is not very far from reality since there is usually no time dependence in the return series, although there may be in the case of volatility. In any case, we note that increasing the length of the sequence strips helps to improve classification. Once the BBRBM-ANN has been trained, the next step is to apply the binarized volatility and return slices of the S&P500 to the BBRBM, whose hidden neurons serve as input for the ANN to generate a prediction. From the ANN output neuron, we obtain the probability values to visualize what the model tells us regarding the presence of volatility. Figure 7 shows the probabilities of having unstable samples generated by the BBRBM-ANN, using them as inputs to the BBRBM slices of \(k=16\) volatility and returns lags. The model consistently predicts a high probability (close to 1) in periods well known as crises (marked in the graph from letters a to d). On the contrary, in periods of long index rises, the model generates very low probabilities of instability. Another interesting observation is that the model occasionally generates probabilities above 0.5 (but not close to 1.0) that tend to occur in index crashes not part of a crisis, capturing some of the noise characteristics of market volatility. Figure 6: ANN performance measures to detect unstable samples using 10-fold cross-validations. ANNs were trained using synthetic samples with different numbers of lags \(k\) of volatility and returns.