October 16, 2026
Inflation Forecast in Brazil using “Random Forest” and Neural Networks
Inflation Forecast in Brazil Using “Random Forest” and Neural Networks
Natália Henrique Dias; Jacques Henrique Dias
DOI: 10.22167/2675-6528-202603316
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
Inflation is a crucial factor for economic decision-making, especially in Brazil, a country with a history of price instability. Given this relevance, the study aimed to develop and compare models for forecasting monthly inflation, measured by the Broad National Consumer Price Index (IPCA). To this end, an empirical study was conducted with macroeconomic data from April 2012 to December 2025, including variables such as the Selic rate, unemployment rate, exchange rate, Central Bank Economic Activity Index (IBC-Br), consumer confidence index, and lags of the IPCA itself. Multiple Linear Regression, Random Forest, and Neural Network models were used. The results indicated that the Random Forest model presented the best predictive performance compared to the traditional linear model, demonstrating a greater ability to capture non-linear relationships and interactions between variables, as well as allowing for the evaluation of the importance of explanatory variables in inflation forecasting. It was concluded that the use of machine learning techniques can improve the accuracy of inflation forecasts in Brazil.
Keywords: IPCA; Machine learning; Predictive models; Time series; Macroeconomic variables.
1. Introduction
Economics, as conceptualized by Froyen (2003), is dedicated to the study of human behavior in its daily activities, focusing on the acquisition and use of material resources for well-being. This field encompasses the actions of various economic agents that influence crucial variables, such as Gross Domestic Product, interest rates, wages, and price levels.
The economic agents of a country, which include households, companies, the Government, and the external sector, directly impact economic activity through the production or consumption of goods (CADE, 2016; ENAP, 2017). Among these, the Government plays a fundamental role in economic regulation, being responsible for implementing policies that affect key economic variables, including price levels.
Inflation arises when there is an imbalance that results in a generalized and persistent increase in price levels, which leads to a reduction in the purchasing power of the population. To measure the inflation rate, an index that reflects the price level of goods and services in a given period is used, with the inflation rate being calculated from the variation of this index (Froyen, 2003).
The Brazilian economic history is marked by periods of high inflation, which generated crises and eroded the purchasing power of the currency. In 1989, the inflation rate reached approximately 1,783%, and in 1993, it reached 2,709%. Given this scenario, combating inflation became a priority in economic policies of the 1990s, culminating in the implementation of the Real Plan in 1994, which effectively stabilized prices (Froyen, 2003; Fernandes et al., 2024).
After these periods of instability, Brazil adopted the inflation targeting regime in 1999, aiming to keep inflation under control (Fernandes et al., 2024). In this regime, the Central Bank of Brazil (BACEN) publicly commits to keeping inflation aligned with a pre-established target, defined by the National Monetary Council (CMN) (BACEN, 2025). The measurement of Brazilian inflation is done through price indices, such as the Broad National Consumer Price Index (IPCA), which is used to determine the target and verify its outcome (BACEN, 2025).
Brazilian monetary policy, under the inflation targeting regime, uses the basic interest rate, SELIC, as the main instrument for inflation control. SELIC is defined by the Monetary Policy Committee (COPOM), and the Central Bank is responsible for executing the necessary operations to achieve this rate (Fernandes et al., 2024). Inflation control is essential for the stability of the currency’s purchasing power, making the ability to predict this variable a crucial element for economic decision-making.
Considering the history of inflationary imbalance in Brazil and the importance of price forecasting for economic stability, this work aims to contribute to the construction of a model for forecasting Brazilian inflation, represented by the monthly IPCA, seeking the lowest possible error level among the studied tools.
2. Material and Methods
This research was characterized as an applied empirical study, using secondary macroeconomic data and a quantitative approach. The main objective was to compare the predictive performance of different modeling techniques for forecasting the monthly Broad National Consumer Price Index (IPCA), seeking the lowest possible error level.
The database used for the construction of the prediction models was composed of 165 monthly data observations, covering the period from April 2012 to December 2025. The definition of this sample period considered the joint availability of the time series used in the study.
The variables chosen to compose the database included the IPCA (dependent variable), unemployment rate, SELIC rate, exchange rate (R$/US$), Consumer Confidence Index (ICC), and the Central Bank’s Index of Economic Activity (IBC-Br). The selection of these variables was based on economic relationships identified in previous studies (Alencar, 2006; Fernandes et al., 2024; Minella, 2003; Silva et al., 2018; Phillips, 1958; Feistel et al., 2018; Edwards, 2006; Khan and Senhadji, 2000; Sum, 2012).
The Gross Domestic Product (GDP) variable was replaced by the IBC-Br, as GDP is released quarterly, while the IBC-Br is published monthly, aligning with the temporal frequency of the forecasting models. To corroborate this choice, an analysis of the correlation between the quarterly Real GDP and the standardized IBC-Br for the quarter was performed, which demonstrated a strong correlation between the two series.
In addition to macroeconomic variables, three variables with lags of the IPCA itself (IPCA t-1, IPCA t-2, and IPCA t-3) were included. This inclusion aimed to capture the impact of inflationary inertia, a characteristic present in the price dynamics in Brazil (Minella et al., 2003).
All data were organized on a monthly frequency and temporally aligned. The unemployment rate, published quarterly, had its result considered for each of the three months that comprised the disclosed quarter. For the exchange rate, reported daily, the daily average of the days that comprised the month was used. Observations with missing values were removed from the database.
The data sources were the Brazilian Institute of Geography and Statistics (IBGE, 2026) for IPCA and unemployment rate, the Central Bank of Brazil (BACEN, 2026) for SELIC rate, exchange rate and IBC-Br, and the Getulio Vargas Foundation (FGV, 2026) for the ICC. With the database assembled, an exploratory analysis was performed through descriptive statistics, calculating measures of central tendency and dispersion of the variables.
In the inflation forecast, three models were used: Multiple Linear Regression, “Random Forest”, and Neural Networks. The “Random Forest” and Neural Networks models were chosen for their ability to handle many variables and identify complex patterns in the data, characteristics observed in macroeconomic variables (Hastie et al., 2009; Goodfellow et al., 2016).
The Multiple Linear Regression model was employed for comparison with “machine learning” models, given its widespread use in econometric studies of inflation (Stock and Watson, 2007). This approach allowed us to evaluate whether “machine learning” techniques generate relevant predictive gains compared to a traditional linear model.
For the predictive performance test of the models, the 165 observations from the database were divided into 80% for training (132 observations, from April 2012 to March 2023) and 20% for testing (33 observations, from April 2023 to December 2025). The training set was used to estimate the model parameters, and the test set was used to evaluate the out-of-sample predictive capacity.
The Multiple Linear Regression model was estimated by Ordinary Least Squares (OLS), with the monthly IPCA as the dependent variable and lagged IPCA and macroeconomic indicators as explanatory variables. The “Random Forest” model was estimated using the training set with 800 trees and random selection of four candidate variables at each split (Breiman, 2001).
For the Neural Networks, a multilayer perceptron (MLP) type neural network was used, composed of a hidden layer with seven neurons. Before training, the variables were normalized to improve the numerical stability and convergence of the optimization algorithm. The training included a penalty term (“decay”) of 0.005 (Hastie et al., 2009).
For the construction of the database and execution of the prediction models, the RStudio software, version 2026.01.0 Build 392, with R version 4.3.2 was used. The predictive performance of the models was compared out-of-sample using two metrics: the Root Mean Squared Error (RMSE) and the Mean Absolute Error (MAE) (Hyndman and Koehler, 2006). RMSE penalizes larger magnitude errors, while MAE assigns the same weight to all errors.
To assess the presence of autocorrelation in the residuals of the Multiple Linear Regression model, the Durbin-Watson and Ljung-Box tests were performed. The existence of multicollinearity among the explanatory variables was evaluated through variance inflation factors (VIF) and their respective tolerance values. As a complementary analysis, the Augmented Dickey-Fuller (ADF) and Kwiatkowski-Phillips-Schmidt-Shin (KPSS) tests were conducted to evaluate the stationarity of the series used.
3. Results and Discussion
The research results revealed significant differences in predictive performance among the models employed for forecasting monthly inflation in Brazil, measured by the IPCA. Initially, an exploratory data analysis provided an understanding of the behavior of macroeconomic variables over the studied period, establishing the basis for subsequent comparisons. The evaluation of error metrics indicated that the “Random Forest” model outperformed the others, demonstrating greater accuracy in capturing inflationary dynamics, which corroborates the relevance of “machine learning” techniques for this type of economic problem.
The analysis of descriptive statistics for the variables, covering 165 monthly observations, showed that the IPCA presented an average of 0.47% with a median of 0.43%, indicating an approximately symmetric distribution. The standard deviation of 0.37 percentage points evidenced relevant variations in inflation over time, with extreme values of -0.68% (deflation) and 1.62% (point inflationary shocks). This volatility underscores the complexity inherent in forecasting the IPCA and the need for robust models capable of handling such fluctuations.
The Selic rate, in turn, registered an average of 9.67% and a median of 10.46%, suggesting the predominance of periods with high interest rates. The range between the minimum of 1.90% and the maximum of 14.90% reflects changes in Brazilian monetary policy, with cycles of stimulus and tightening. The unemployment rate, with an average of 9.7% and a median of 9.0%, and a standard deviation of 2.8 percentage points, indicated significant variations in the labor market, with peaks of 14.9% and minimums of 5.1%, reflecting phases of economic deterioration and dynamism, respectively.
The Central Bank’s Economic Activity Index (IBC-Br) showed a mean of 99.4 and a median of 99.1, with a symmetric distribution and moderate oscillations (standard deviation of 5.6). The variation between 83.6 and 114.2 evidenced economic cycles and production shocks. The Consumer Confidence Index (ICC) had a mean of 86.3 and a median of 86.6, with a standard deviation of 10.9, indicating significant variations in consumer expectations, with moments of pessimism (60.2) and high confidence (114.4) throughout the analyzed period.
Finally, the exchange rate registered an average of R$ 4.02 per dollar and a standard deviation of 1.25, evidencing its volatility. The range between R$ 1.85 and R$ 6.10 per dollar revealed periods of currency appreciation and depreciation, crucial factors for inflationary dynamics. The inclusion of lags of the IPCA itself (t-1, t-2, and t-3) in the database aimed to capture inflationary inertia, a recognized characteristic in price dynamics in Brazil (Minella et al., 2003).
Predictive Performance of the Models
The comparison of the predictive performance of the models was carried out using the Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE) metrics on the test set, which comprised 33 observations from April 2023 to December 2025. The results indicated that the “Random Forest” model obtained the lowest RMSE, with a value of 0.28, and the lowest MAE, with a value of 0.20. In contrast, the Multiple Linear Regression model presented an RMSE of 0.33 and an MAE of 0.26, while the Neural Networks registered the highest errors, with an RMSE of 0.49 and an MAE of 0.38.
These findings demonstrate that the “Random Forest” model was the most effective in capturing the dynamics of monthly inflation in the analyzed period, outperforming both the traditional linear model and Neural Networks. The superior performance of “Random Forest” is attributed to its ability to handle non-linear relationships and complex interactions between macroeconomic variables, characteristics frequently present in economic data (Varian, 2014). The robustness of this technique in high-complexity scenarios makes it particularly suitable for inflation forecasting in the Brazilian context.
In addition to predictive evaluation, the statistical results of the Multiple Linear Regression model, estimated by the Ordinary Least Squares (OLS) method, were analyzed. Among the estimated coefficients, only the first lag of IPCA (IPCA t-1) showed statistical significance at the 5% level, with a coefficient of 0.5192 and a p-value below 0.001. This positive coefficient indicates that increases in the previous period’s IPCA are associated with increases in the current IPCA, evidencing the persistence of inflation, a widely recognized phenomenon in the Brazilian economy.
The other explanatory variables included in the Multiple Linear Regression model – Selic, unemployment, IBC-Br, ICC, and exchange rate, as well as the lags IPCA t-2 and IPCA t-3 – did not show individual statistical significance at the 5% level. This suggests that, although these variables are theoretically relevant to inflation, their direct linear relationships with the current IPCA may not be statistically robust in the linear model, or their interactions are more complex than the linear model can capture.
The adjustment measures of the Multiple Linear Regression model revealed an R² of 0.3498 and an adjusted R² of 0.3075. This means that approximately 34.98% of the variability of the IPCA in the training sample is explained by the variables included in the model. The F-statistic, with a value of 8.272 and a p-value less than 0.001, indicated that the explanatory variables are jointly significant, reinforcing the overall validity of the model, despite the lack of individual significance of some variables.
To verify the presence of autocorrelation in the residuals of the Multiple Linear Regression model, the Durbin-Watson and Ljung-Box tests were applied. The Durbin-Watson test resulted in a statistic of 1.9861 and a p-value of 0.3029, not rejecting the null hypothesis of absence of first-order positive autocorrelation at the 5% significance level. The Ljung-Box test, considering 12 lags, presented a statistic of 8.7195 and a p-value of 0.7267, also not rejecting the null hypothesis of absence of joint autocorrelation. These results indicate that no statistical evidence of relevant autocorrelation was identified in the residuals of the linear model.
The assessment of multicollinearity among the explanatory variables was performed using variance inflation factors (VIF) and tolerance values. VIF values ranged from 1.54 to 3.73, while tolerance values were between 0.27 and 0.65. The highest VIF was observed for the unemployment rate (3.73), followed by ICC (3.59). Considering these values, no evidence of relevant multicollinearity was identified, ensuring that the coefficient estimates were not unduly influenced by high correlation among the predictor variables.
The Augmented Dickey-Fuller (ADF) and Kwiatkowski-Phillips-Schmidt-Shin (KPSS) stationarity tests indicated that the IPCA was stationary at level. However, the Selic rate, unemployment rate, IBC-Br, consumer confidence index, and exchange rate series showed evidence of non-stationarity at level, but became stationary after applying the first difference. For the Selic rate, the tests were inconclusive in the first difference, which is a point to consider when interpreting the results.
Importance of variables in “Random Forest”
The analysis of the importance of variables in the “Random Forest” model was conducted through the %IncMSE (Percent Increase in Mean Squared Error) level, which quantifies the percentage increase in the model’s mean squared error when a variable’s values are shuffled. The higher the %IncMSE, the greater the variable’s relevance to the model’s predictive capability. The results indicated that the one-month lag of IPCA (ipca_lag1) was the most relevant variable, reinforcing the strong dependence of current inflation on its past behavior, a reflection of inflationary inertia.
Other variables that showed relevant contribution to the performance of the “Random Forest” model included the unemployment rate, the Consumer Confidence Index (ICC), the Selic rate, and the exchange rate. The IBC-Br and the IPCA t-2 and IPCA t-3 lags showed less relative importance. From an economic point of view, this hierarchy of variables is consistent with hybrid inflation models, which recognize the interaction of past price dynamics, the level of activity, and monetary policy in determining current inflation (Minella et al., 2003).
Random Forest Decision Tree
The structure of one of the decision trees in the “Random Forest” illustrated how the model uses sequential rules based on explanatory variables to make predictions. The first splits of the tree occurred based on the lagged IPCA (ipca_lag1), confirming its central role in inflationary dynamics. When ipca_lag1 was less than 0.47, the model directed to branches associated with more moderate inflation predictions. On the other hand, when ipca_lag1 was greater than or equal to 0.47, predictions tended to be higher.
A notable point in the tree is that, in scenarios of very low IPCA t-1 (below 0.075), inflation forecast was quite reduced (0.089). In situations where past IPCA was low, but not as extreme (greater than or equal to 0.075), exchange rate and unemployment became relevant variables. It was observed that, with higher unemployment, the predicted inflation was lower, and with lower unemployment, the forecast was higher, which is consistent with economic theory that idleness in the economy reduces inflationary pressures. In contexts of higher inflation (ipca_lag1 greater than or equal to 0.68), the ICC became an important division criterion.
These patterns demonstrate that the “Random Forest” model is capable of capturing conditional interactions between macroeconomic factors, revealing that inflationary dynamics are non-linear and context-dependent. The effect of a predictor can vary depending on the value of another, a complexity that traditional linear models struggle to represent. This ability to identify complex patterns without prior specification reinforces the advantage of tree-based methods in problems with complex dynamics.
Analysis of Predicted Values and Residuals of Neural Networks
The analysis of observed versus predicted values for the Neural Networks model revealed considerable dispersion relative to the 45-degree line, indicating lower predictive accuracy compared to the “Random Forest”. This behavior may be associated with the sensitivity of neural networks to sample size. The graphical analysis of the residuals of the Neural Networks model on the test set indicated a greater dispersion of errors for higher values of predicted inflation, suggesting the presence of heteroscedasticity or the model’s difficulty in handling periods of higher volatility.
This inferior performance of Neural Networks suggests that the model may not have been able to adequately capture the data structure with the available information set, possibly due to the relatively small sample size and the inherent complexity of the model. Neural networks, in general, require a larger volume of data to robustly estimate a large number of parameters, which can lead to problems of “overfitting” or poor generalization in smaller samples (Goodfellow et al., 2016).
The comparison of observed and predicted values for all models in the test period showed that “Random Forest” was the one that most closely followed the IPCA oscillations. The Multiple Linear Regression model presented a smoother behavior, with a tendency to underestimate sharper peaks and troughs. Neural Networks, in turn, exhibited greater variation at specific moments, but with lower overall precision.
Despite the superior performance of the “Random Forest”, a trend of smoothing extreme IPCA values was observed. For example, in February 2025, the observed IPCA was 1.31%, while the model’s forecast was 0.21%, resulting in an error of approximately 1.10 percentage points. This underestimation of peaks was not solely attributed to the extrapolation of explanatory variables, as most of them remained within the ranges observed during training, with the exception of the exchange rate, which showed a value slightly higher than the maximum observed. This suggests a difficulty for the model in reproducing extreme IPCA values when the characteristics observed in the test period do not find sufficiently similar situations in the training set.
In summary, the research results indicate that the “Random Forest” model presented the best predictive performance for Brazilian monthly inflation, outperforming Multiple Linear Regression and Neural Networks. This superiority is attributed to its ability to capture non-linear relationships and complex interactions among macroeconomic variables. Inflation inertia, measured by the lag of the IPCA, proved to be the most relevant factor, while variables such as unemployment, consumer confidence, Selic rate, and exchange rate also played important roles. These findings reinforce the utility of “machine learning” techniques for improving the accuracy of inflation forecasts in Brazil, especially in scenarios with complex and non-linear dynamics.
4. Conclusion
This study aimed to develop and compare inflation forecasting models for Brazil’s monthly inflation, measured by the Broad Consumer Price Index (IPCA), seeking the lowest possible error level among the analyzed tools. It was found that the “Random Forest” model showed the best predictive performance, with the lowest Root Mean Squared Error (RMSE) values of 0.28 and Mean Absolute Error (MAE) of 0.20, outperforming Multiple Linear Regression and Neural Networks. This superiority was attributed to “Random Forest’s” ability to capture non-linear relationships and complex interactions among macroeconomic variables. The one-month lag of IPCA (ipca_lag1) was identified as the most relevant variable for forecasting, reinforcing inflationary inertia, while the unemployment rate, the Consumer Confidence Index (ICC), the Selic rate, and the exchange rate also played important roles. The main contribution of this work lies in demonstrating that the use of “machine learning” techniques, such as “Random Forest”, can significantly improve the accuracy of inflation forecasts in the Brazilian context, offering a more robust tool for economic decision-making.
Despite the superior performance of the “Random Forest”, a limitation was observed in the model’s ability to reproduce extreme values of the IPCA, showing a tendency to smooth out sharp peaks and troughs, even when the explanatory variables remained within the training ranges. This difficulty suggests that the model may not have encountered sufficiently similar situations in the training set to predict atypical inflationary events. Additionally, the inferior performance of Neural Networks was associated with their sensitivity to sample size and inherent complexity, which may have limited learning and generalization in a relatively small dataset. Stationarity tests for the Selic rate were also inconclusive in the first difference, demanding caution in interpreting its effects. For future studies, it is suggested to explore approaches that can mitigate the smoothing of extreme values, as well as investigate the application of Neural Networks on more extensive databases to optimize their predictive potential.
Bibliographic References
Alencar, B.K. 2006. Modelos de Previsão da Inflação: uma análise comparativa no curto prazo. Dissertação de Mestrado Profissionalizante em Economia. Ibmec, Rio de Janeiro, RJ, Brasil.
Banco Central do Brasil [BACEN]. 2025. Metas para a Inflação. Disponível em: <https://www.bcb.gov.br/controleinflacao/metainflacao>. Acesso em: 11 out. 2025.
Conselho Administrativo de Defesa Econômica [CADE]. 2016. Cartilha do CADE. Disponível em: <https://cdn.cade.gov.br/Portal/acesso-a-informacao/perguntas-frequentes/cartilha-do-cade.pdf>. Acesso em: 11 out. 2025.
Escola Nacional de Administração Pública [ENAP]. 2017. Introdução ao Estudo da Economia do Setor Público. Disponível em: <http://repositorio.enap.gov.br/handle/1/3237>. Acesso em: 12 out. 2025.
Fernandes, V.R.V.; Ferreira, F.D.S.; Souza, J.A.N.; Leandro, D. 2024. Política Monetária e Taxa Básica de Juros no Brasil: uma análise do papel das taxas de juros em um regime de metas de inflação. Revista de Estudos Sociais 23(47): 126-146. Disponível em: <https://periodicoscientificos.ufmt.br/ojs/index.php/res/article/view/10910>. Acesso em: 12 out. 2025.
Froyen, R. T. 2003. Macroeconomia. 5ed. Editora Saraiva, São Paulo, SP, Brasil.
Minella, A. 2003. Monetary Policy and Inflation in Brazil (1975-2000): a VAR estimation. Revista Brasileira de Economia 57(3): 605-635. Disponível em: <https://doi.org/10.1590/S0034-71402003000300005>. Acesso em: 15 out. 2025.
Silva, E.V.A.; Oliveira
Article originating from the Final Course Work of the Specialization in Data Science and Analytics of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform