## 2 Literature Review
### Bibliometric Review
```
1:\(time\_series\)
2:\(ganger\_var\)
3:\(test\_data\gets time\_series[-24:]\)
4:\(train\_data\gets time\_series[:-24]\)
5:\(smoothed\_data\gets smooth(time\_series)\)
6:procedureoptimal_case(time\_series,exogenous)
7:\(best\_MAPE\gets 100\)
8:\(best\_cases:=[]\)
9:\(optimal\_window:=\{\}\)
10:for\(i=1\) to \(6\)do
11:for each model in models do
12:\(train\_window\leftarrow train\_data[-i*36:]\)
13:\(model\_train(train\_window,exogenous)\)
14:\(prediction\gets model\_predict(24 months)\)
15:\(MAPE\gets get\_map(prediction,test\_data)\)
16:if\(MAPE<best\_MAPE\)then
17:\(optimal\_window\{model\}\gets i*36\)
18:endif
19:endfor
20:endfor
21:return\(optimal\_window\)
22:endprocedure
23:\(optimal\_original\gets optimal\_case(time\_series,None)\)
24:\(optimal\_smoothed\gets optimal\_case(smoothed\_data,None)\)
25:\(optimal\_original\_exo\gets optimal\_case(time\_series,ganger\_var)\)
26:\(optimal\_smoothed\_exo\gets optimal\_case(smoothed\_data,ganger\_var)\)
27:for each model in models do
28:\(model\_train(optimal\_original)\)
29:\(model\_predict(120 months)\)
30:\(model\_train(optimal\_smoothed)\)
31:\(model\_predict(120 months)\)
32:endfor
```

**Algorithm 2** Forecasting

The MAPE offers a measure of the average percentage difference between the predicted and actual values, offering perspective into the relative magnitude of errors while inherently accounting for the scale of the data. As a complement, MPE provides an indication of directional bias by measuring the average percentage difference between the predicted and actual values without absolute value transformation, thereby discerning whether predictions consistently overestimate or underestimate actual values. Furthermore, RMSE offers a measure of the typical magnitude of errors, while penalizing larger errors. Finally, NRMSE_minmax normalizes the RMSE by the range of actual values, allowing for a comparison of predictive accuracy relative to the variability of the data. These metrics are calculated by Equations (1)-(4), in which \(y\) represents the actual data and \(\hat{y}\) represents the predicted value. \[\text{MAPE}=\frac{100\%}{n}\sum_{i=1}^{n}\left|\frac{y_{i}-\hat{y}_{i}}{y_{i}}\right| \tag{1}\]

\[\text{MPE}=\frac{100\%}{n}\sum_{i=1}^{n}\left(\frac{y_{i}-\hat{y}_{i}}{y_{i}}\right) \tag{2}\]

\[\text{RMSE}=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\hat{y}_{i})^{2}} \tag{3}\]\[\text{NRMSE\_mimmax}=\frac{\text{RMSE}}{\text{max}(y)-\text{min}(y)} \tag{4}\]

These metrics elucidate each model's capability to predict energy demand. In addition to assessing the individual performance of the forecasting models, this study inquires about the influence of external factors on energy consumption trends. External variables, selected according to the Granger tests, are examined alongside the forecasting models to assess their impact on energy demand patterns. For the section of the work in which we evaluate the impacts of exogenous variables, SARIMAX is used instead of SARIMA. The multivariate models are run on SARIMAX and FB Prophet exclusively, as Holt-Winters and TBATS do not support this type of forecasting. In addition to the accuracy metrics, the models' fit is also evaluated, with the Ljung-Box test. This test evaluates whether the model has successfully captured the time series structure by checking for remaining autocorrelations in the residuals. If the residuals show no significant autocorrelation, the model is considered a good fit. The accuracy and fitness of the models are evaluated for different training window sizes, and the optimal scenario is selected for forecasting the energy consumption in Brazil up to 2033. Ultimately, we also measure the time for training and predicting with each model. A comparative analysis evaluates each forecasting model's strengths and weaknesses in predicting Brazil's energy demand trends. This assessment considers factors such as prediction precision, computational speed, and the ability to manage external factors, offering perspectives into the algorithms' practical applicability in real-world situations.