Abstract
Our study examined the disaggregation of inflation components in Nigeria using the stacked ensemble approach, a machine learning algorithm capable of compensating the weakness of an ensemble and a base learner with the strength of another. This approach gives flexibility of a synergistic performance of stacking each base learner and produces a formidable model that yields a high level of accuracy and predictive ability. We analyzed the test data, out-of-sample, and our analyses reveals a robust inflation prediction results. In particular, we show that food CPI is the most important driver for headline urban, and rural inflation while bread and cereals is the most important driver for food inflation in Nigeria. Also, biscuits, agric rice, garri white were found to be among the top main drivers of bread and cereal inflation. Our study further shows that some components of the CPI baskets that majorly drive inflation were assigned lower weights. Hence, attention to CPI weights only, without recourse to understanding the tipping source, may undermined a successful control of inflation in Nigeria. Tracing and tracking the source of inflation to the least sub-component will help resolve inflation problem.
Supplementary Information
The online version contains supplementary material available at 10.1007/s43546-022-00384-2.
Keywords: Headline inflation, Stacked ensemble, Machine learning, Base learner
Introduction
Intellectual discourse on dynamics and drivers of inflation has received overwhelming attention in modern macroeconomic renditions. This profound attention stems from the deleterious effects associated with persistent and unrestrained inflation in an economy. Beyond this point, inflation is known to generally impose constraints on a spectrum of important macroeconomic variables such as savings, investments, exchange rate, trade balance, wellbeing, competitiveness and other parameters that influence overall economic performance of a country (Ashraf et al. 2013; Mbutor 2013; Shaibu and Osamwoni 2020; Tumala et al. 2017). In Nigeria, inflation has been consistently high and stuck in double digits for many years. Over the period of 2018–2020, headline inflation rate averaged 11.95 in 40 years in spite of swift policy responses from the monetary authority. The persistent increase in inflation makes poverty bite harder in a country where over 82.5 million citizens are already poor. The adverse effect of inflation also includes reduction in purchasing power of fixed income earners and decline in general welfare through misallocation of consumption (Krugman et al. 1982). Therefore, management and control of inflation by the monetary authorities is crucial for the attainment of macroeconomic stability. Hence, Central banks make effort to forecast inflation with utmost precision to ensure the effectiveness of monetary policy (Doguwa and Alade 2013).
Existing studies have adopted several short term forecasting models to predict inflation trend. These models vary from multivariate (Kelikume and Salami 2014; Gaomab 1998; Capolongo and Pacella 2020) to univariate structural models (Akdogan et al. 2012; Junttila and Korhonen 2011; Pufnik 2006). Specific examples include the augmented Philips curve models (Greon et al. 2013; Stock and Watson 2008) and the random walk models. These models are, however, not without their shortcomings. They suffer from overfitting problem which results from low dimensionality1. Overfitting occurs when a complex model fits trained data but fails to fit the test data thereby weakening the predictive power of the model. An overfitted model yields high prediction error when forecasting outside the sample. For this reason, many time series models are less robust and yields less accurate inflation forecasts. Machine Learning provides an alternative approach that resolves the overfitting problem. Solving overfitting problems have been a major breakthrough in Machine Learning (ML) algorithms and it has been used to forecast inflation with high accuracy. To rectify overfitting, predictors are pre-selected using some theoretical construct by fine tuning the parameter of the training sample, this is called ‘hyperparameters’ method.
Recently, some ML models, such as Principal Components Analysis, random forest, LASSO regression (Least Absolute Shrinkage and Selection Operator), Decision Trees etc, have been used to forecast inflation (see details in (Baybuza 2018) and (Medeiros et al. 2019)). In spite of numerous advantages of using ML for analyzing and forecasting inflation, a single model or an ensemble approach may be insufficient in addressing the variance-bias problem associated with ML algorithms.Stack ensemble approach becomes sought after to address the problem. It involves combining the prediction results of selected ML models, through a meta-learner to make final predictions. A Meta learner is selected by comparing its loss function estimated by the Root Mean Squared Errors (RMSE) with that of other base learners. Through this,the weaknesses of each learners are eliminated and their strengthens are harnessed to produce a more accurate predictions. Capistran et al. (2010) paper shows that the best forecasts are obtained by combining individual models to use the information contained in them.
Inflation forecast studies have been conducted in isolation from inflation drivers and many of the studies have focused more on macroeconomic variables. In this study, the two issues - first is the identification of CPI-inflation drivers and second is the forecast using the drivers - will be addressed in Nigeria economic context using stacked ensemble approach. To the best of our knowledge, this study is the first to adopt stacked ensemble approach to track the sources of inflation by identifying its drivers and then use the same drivers to predict the inflation. To do this, we disaggregate inflation data into different components and conduct a comparative analysis of the base learners by stacking each base learner into ensemble model to understand the inflation framework in Nigeria. In addition, we trace the sources of inflation by identifying the main drivers of each inflation component. Finally, we predict the test data of each inflation components and as well forecast it over twenty-five months. Two ensembles were trained, namely Random Forest (RF) and Gradient Boosting Machines (GBMs) while Generalized Linear Models (GLM) served as base learners. Each of this base learners were trained to obtain the meta learner for our stacked ensemble and used to predict inflation drivers for Nigeria, an approach that is peculiar to this study. Our results are robust when compared with the baseline model, the two individual ensembles, and the GLM.
The study will be useful to economists and other policy makers as it proposes the use of machine learning for inflation forecasting in Nigeria. The paper also offers procedural insight needed to explore this better approach. Finally, the study will help the government direct policy to specific components of CPI that exacerbate inflation. In particular, food CPI has been assigned a higher weight among inflation components but the specific item in the basket of food CPI that is responsible for the higher weights can easily be tracked. Hence, policy could be directed to that specific component instead of the entire food CPI basket. The rest of the paper is structured as follows; “Literature review” contains a brief review of theoretical and empirical literature. “Methods” contains discussion of the methods while the subsequent section presents the “Results” of the study. Finally, “Conclusion and policy recommendation” contains the summary, conclusion and policy recommendations of the study.
Literature review
The theoretical underpinnings of inflation drivers are embodied by the expositions of orthodox economists from the Classical to Neo-Structuralist. Leading monetarists like (Brunner and Meltzer 1976; Friedman 1956, 1970; Parking 1975) postulated that the rate of growth and the change in money supply explain the rate of inflation and its acceleration. Hence, money supply is the main driver of inflation. Keynesians viewed inflation as a phenomenon driven by excessive spending relative to available goods and services at full employment. Thus, money supply in excess of potential output will, in effect, drive inflation (Javed et al. 2010). Structuralists were persuaded that inflation is mainly driven by imbalances in an economy, especially in developing countries. Such imbalances include infrastructural bottlenecks, emergence of monopolistic and oligopolistic market structure (market imperfection), agricultural bottlenecks, government budget constraints, income elasticities, distortion in government policies and exchange rates amongst others (Agnor and Montiel 1996; Kirkpatrick and Nixon 1987). Empirically, a plethora of studies have lent credence to the above theoretical submissions and further identified other key drivers of inflation using various econometric models. Inflation in Nigeria has been found to be driven by money supply, exchange rate, net exports, interest rates, fiscal factors, agro-climatic factor and real output (Agnor et al. 2018; Asogu 1991; Bayo 2011; Fakiyesi 1996; Imimole and Enoma 2011; Moser 1995; Odusanya and Atanda 2010). Other determinants include petroleum prices, expected inflation, lagged CPI and real exchange rate (Olubusoye and Oyaromade 2008).
In an empirical attempt to forecast inflation in Bangladesh, Younus and Roy (2016) employed an Unrestricted VAR Model. Inflation rate was modelled alongside other macroeconomic variables which included broad money (M2), exchange rate, private sector credit, interest rates, global food price real GDP growth rate. The result suggested that money supply (M2) and interest rates were the most relevant variables for predicting inflation in Bangladesh. Bjornland et al. (2009) used a combination of six models, namely; Vector Autoregressive (VAR), Bayesian Vector Autoregressive (BVAR), Autoregressive Integrated Moving Average (ARIMA), Error Correction Model (ECM), Factor Model and Dynamic Stochastic General Equilibrium (DSGE) models to forecast inflation in Norway. Among the variables adopted were interest rates, inflation, exchange rate, oil price, investment growth and employment rates for the period spanning 1987–1998. The result showed that model combination approach yield better forecast than individual models.
Review of inflation disaggregation
Following the disaggregation of inflation components, some scholars have argued that core inflation can efficiently predict headline inflation (Crone et al. 2013; Le Bihan and Sedillot 2000; Tekatli 2010; Freeman 1998). Thus, core inflation is a good measure for capturing trends in headline inflation and this justifies why it is preferred as a guide for monetary policy (Miskin 2007). Yet, there are counter arguments against the use of core inflation to predict total inflation. First of such arguments is that core inflation loses its predictive power as a result of removal of items on which people spend most of their income. Also, changes in energy consumption caused by changes in price will eventually exert pressure on all other prices in the economy (Bullard 2011). Pincheira et al. (2016) empirically investigated the ability of core inflation to forecast headline inflation in 33 countries using in-sample and out-of-sample analysis. The in-sample analysis confirmed predictability from core to headline while out-of-sample analysis showed that core predicted headline in about two-third of countries in the study. Nevertheless, in literature, there are other approaches of predicting inflation. In addition to previous studies, Stock and Watson (2008) argued that forecasting and measuring inflation is a difficult task but it is critical for effective monetary implementation . This task generally requires the disaggregation of inflation into its transitory and persistent components (Atuk and Ozmen 2009). Headline inflation, which is the transitory component, poses a challenge in the process of determining its underlying trend. This is due to its susceptibility to shocks which are beyond the control of policy makers(Odo et al. 2016; Roger 1998). This shortcoming necessitated the call for exclusion of items driving volatility in general price level (Bryan and Cecchetti 1994; Cecchetti and Wiggins 1997) thereby birthing the concept of Core inflation which is regarded as a persistent component of inflation. Core inflation is further disaggregated into Core 1 and Core 2, where Core 1 excludes food beverages and tobacco Core 2 excludes food, beverage, tobacco, energy prices, and mortgage interest from the food basket. This exclusion is based on the fact that, historically, food and energy have proven to be highly volatile (Pincheira et al. 2016). In this study, we simplified each CPI basket to its main components and focus on the important variables which can provide more information on the main source of inflation. This approach provides a clear direction to addressing persistent inflation in Nigeria.
Review of methods of inflation forecasting
The literature is rich with empirical studies on inflation forecasting. These studies adopt diverse models and methods across countries in their quest to attain higher precision in forecasting inflation. Specifically, (Stock and Watson 2007) and (Gurkaynak et al. 2005) employed unobserved components stochastic volatility model. Cogley and Sbordone (2008) used the New Keynesian Model while De-Graeve et al. (2009) adopted on New Keynesian Phillips curve (NKPC) approach. Medium-scale macro-finance Dynamic Stochastic General Equilibrium (DSGE) Model was used by Gonzales et al. (2011); penalised likelihood by Dotsey et al. (2017), while Clark and Doh (2011) used Bayesian methods to forecast inflation. An extensive review on literature has been done by (Faust and Wright 2013). Since early 1960s, Phillips curve models have been widely used for inflation forecasting. But in the past two decades, empirical studies began to cast shadow on the predictive power of Phillips curve models as they could not outperform the naive method in terms of precision (Dotsey et al. 2017). The authors found that forecasts from Phillips curve models tend to be unconditionally inferior to those of univariate forecasting models. In fact, Atkeson and Ohanian (2001), found that Phillips-curve models are less accurate than naive models in forecasting inflation. There is evidence in literature that Phillips curve alone is not sufficient to accurately forecast inflation. Stock and Watson (1999) proposed the introduction of supply side variables for better performance. Univariate and multivariate models have also been employed for inflation forecasting over the years. Univariate models (based on ARIMA and ARCH models) are usually adopted for short term forecasting while multivariate models (VAR and cointegration) are famous for long term forecasting (Fawad et al. 2015). Even the renowned Phillips curve are mostly based on VAR models. These models have been used to analyze and forecast inflation in several countries. For instance, Pufnik and K (2006) used univariate model to forecast Croatia’s inflation while Gaomab (1998) used multivariate model to forecast inflation in Namibia. Akdogan et al. (2012) adopted univariate ARIMA model in Turkey and compared results obtained with those of other models and found that models with more economic information produces better forecast. Kelikume and Salami (2014) employed both univariate and multivariate models to forecast inflation in Nigeria and found that VAR model had smaller errors in terms of the minimum square error and it is the closest approximate to current inflation in Nigeria. It has however been argued that univariate models are mere scientific guesses with some confidence interval and are poor in predicting turning points. Such models therefore, provide weak forecast when volatile and high frequency data are involved (Meyler et al. 1998). Multivariate models on the other hand have been criticized for being too complex and prone to misspecification errors and overfitting problems.
In forecasting monthly inflation rate in Nigeria, the findings of Amadi et al. (2013) suggested that SARIMA was the best model to adopt. Similarly, Doguwa and Alade (2013) proposed four short term forecasting models using SARIMA and SARIMAX processes. The models incorporated some endogenous variables which include PMS price, government expenditure, net credit to central government, average monthly rainfall in cereals producing north central zone, nominal Bureau-de-change exchange rate, broad money supply (M2), official nominal exchange rate, reserve money, credit to private sector and average monthly rainfall in vegetables producing southern zone. Based on the result, the paper recommended that all-item CPI, estimated using SARIMAX model, should be adopted for short-term forecasting of headline inflation in Nigeria. It also suggested that SARIMA model was the best for forecasting core inflation in Nigeria. Omekara et al. (2013) employed Periodogram and Fourier series analysis to model Nigerian monthly inflation rates. The forecasts were found to be accurate and reliable for Nigeria. Okafor and Shaibu (2013) adopted ARIMA model in line with Box Jenkins (1976) to forecast inflation using CPI data from 1981 to 2010. The paper found ARIMA (2,2,3) as the most appropriate for the country. On the contrary, Yemitan and Shittu (2015) applied Kalman filter technique and found it more efficient than Box Jenkins. Our methods in identifying main drivers of inflation includes the ARIMA, which is the baseline, the cross validated and hyper-parameter tuning of the ensembles, RF and GBM, and the cross validated and hyper-parameter tuning of the GLM. All these methods address the fundamental questions of what the best model should be. The weakness of each ensemble model necessitated the adoption of cross validated stacked ensemble approach to enhance predictability of the model. This is one of the strengths of this study. We found that the optimal hyper-parameters we obtained provides the best predictive accuracy. In addition, we confirmed that the base learners have high variability and are uncorrelated.
Review of inflation drivers and its forecasts using machine learning
Inflation narratives have been influenced by studies exploring its drivers and future trajectory through forecasts. In many cases, these two strands of literature has been explored separately. In exploring its drivers, just like this study, few empirical studies have identified inflation drivers using machine learning algorithm. Benalal et al. (2004) investigates whether the forecast of the Harmonized Index of Consumer Prices (HICP) components improve upon the forecast of overall HICP. Giannone et al. (2014) constructed Bayesian Vector Autoregressive model (BVAR) that captures the inter-relationships between the main components of the HICP and their determinants in the Euro area while Oren et al. (2021) used the Recurrent Neural Networks (RNNs) for predicting disaggregated inflation components of the Consumer Price Index (CPI). In addition to the identification of inflation drivers and its components, empirical studies on inflation forecast using other macroeconomic variables have also received a considerable attention. Inoue and Lutz (2008) adopted bagging, factor models, and other linear shrinkage estimators to forecast inflation in the US. Similarly, Medeiros and Mendesy (2016) employ adaptive LASSO to forecast US inflation while Medeiros et al. (2019) show that LASSO and Random forest are more accurate forecasts than the standard benchmarks. Other ML methods that have been used for inflation forecasting include heuristic and variable selection method (Kapetanios et al. (2016), shrinkage and complete subset regression (CSR) method (Gracia et al. 2017). Baybuza (2018) in particular applied several ML methods such as RF, Least Absolute Shrinkage and Selection Operator (LASSO), Ridge, Elastic Net and Boosting to forecast inflation in Russia. Findings of the study confirm the possibility of forecasting inflation with a higher level of precision compared to other traditional models like Random Walk and Autoregression.
There are four important features of ML; nonlinearities, regularization, cross-validation and alternative loss function, out of which nonlinearity feature was found to be the true game changer for macroeconomic forecasting (Coulombe et al. 2019). Gracia et al. (2017) used ML methods to forecast inflation in Brazil and found that LASSO model is best for shorter forecast. Similarly, Gu et al. (2018) found significant improvement in the prediction of out-of-sample (test data) stock return using ML methods on 30,000 samples, over 900 baseline signals and hundreds of predictors. Medeiros et al. (2019) in forecasting US inflation found that ML models, with a large number of covariates, are systematically more accurate than the benchmarks for several forecasting horizons both in the 1990s and the 2000s. The ML method that deserves more attention is the RF, which dominated all other models in several cases. Malhotra and Maloob (2017) employed gradient Boosted Regression Trees (BRT) technique of ML to analyzed inflation in India and submitted that all predictor variables used in the model were significant in predicting food inflation in India. In addition to what has been written, Onimode et al. (2015) used the artificial neural networks (ANN) and found that neural network is more efficient than univariate autoregressive models in forecasting inflation up to four quarters ahead.
This study differs from other studies as it proposes the application of a robust approach in identifying inflation drivers and providing a forecast for its components. In essence, we obtained the drivers to identify the source of each CPI-inflation components, predict the out-of-sample CPI-inflation data, and forecast inflation in twenty-five horizons.
Stylised facts on inflation trends in Nigeria (1973–2020)
Since early 1970s, the country has been experiencing sequence of inflation episodes. Thus, inflation has remained one of the major macroeconomic problems in Nigeria. The first oil boom of 1973 brought about a sudden upsurge in government revenue and as a result, government began to embark on massive developmental projects across the country as part of its reconstruction efforts after the civil war (Asekunowo 2016). Resultantly, there was a sudden spike in money stock in the economy without a corresponding increase in production of goods and services. Inflationary pressure was further aggravated by the enormous increase in minimum wage following the recommendation of the Udoji committee in 1974. Inflation rate in Nigeria soared to an average of 33.7% in 1975. As inflationary pressure continued to mount, policy makers came under intense pressure to respond appropriately. One of the policy responses was the change in monetary policy framework from exchange rate targeting to monetary targeting in 1974. Other policy measures taken include credit expansion to productive sector of the economy and the liberalisation of import which encouraged huge importation of cheaper goods. Consequently, by 1979, inflation rate had fallen to 11.8% (Nse et al. 2018). Again, inflationary pressure began to mount up in the early 80s as the country had become import dependent with attendant balance of payment problems. By 1984, inflation had risen to 41.2%, which necessitated the devaluation of the naira and the adoption of price control measures to bring down inflation to 5.5% and 5.4% in 1985 and 1986 respectively. Inflation in Nigeria reached its all-time peak in 1995 when it rose to 79.9%. By 1999 it had fallen to 6.6% consequent upon the adoption of effective monetary, fiscal and exchange rate policy.
Over the period 2003 to 2005, inflation rate in Nigeria averaged 15.7% owing to increasing budget deficits. However, following the implementation of sound monetary and fiscal policies, coupled with robust agricultural harvests, inflation rate declined to an average low of 5.4% by 2007 (Doguwa 2012). The advent of the Global Financial Crisis resulted in another spike in inflation rate to 12.6% by 2009. The rate of inflation remained high at over 12% in 2012 owing to non-monetary factors such as severe flooding in some regions. By 2013, CPI inflation had declined to 8% but could not be sustained as a result of oil price shock in the period 2014–2018. Again, recovery in oil price led to a decrease in inflation rate to an average of 11.4% in 2019.
A disaggregated analysis of inflation trend in Nigeria showed that there is a co-movement in headline, core and food components for most years except for periods between 1998–1999 and 2001–2004 (See Fig. 1)2.
Fig. 1.
Quarterly headline, core, and food inflation
Most recently, there has been a persistent upward movement in the three inflation components in Nigeria attributed largely to the adverse effect of COVID-19 pandemic and other policies like the proposed removal of fuel subsidy which aimed at improving the fiscal position of government. Besides, the recent hike in electricity tariff is expected to exacerbate inflation problem. According to National Bureau of Statistics(NBS), Nigeria’s headline and core inflation for August 2020 stood at 13.22% and 10.52% respectively which was the highest in 29 months since March 2018 (13.24%)3.
Fig. 2.
Headline and core inflation in Nigeria (Jan–Aug 2020)
Inflation persistence is the tendency for price shocks to push the inflation rate away from its steady state-including an inflation target-for a prolonged period (Roache 2013). In other words, it is a measure of tendency of inflation rate to retain its current status. The mandate of most monetary authorities is to reduce the extent to which inflation persists overtime. Recent empirical study of inflation persistence in Nigeria by Tule et al. (2020), using fractional cointegration VAR model, revealed evidence of high inflation persistence with a lower trend after the global financial crisis. Inflation data of Nigeria from 1973 to 2013 shows that out of forty-seven (47) year observations, headline inflation has hovered or persisted around double digits for 37 years. This is as shown in Fig. 3 below.
Fig. 3.
Annual headline inflation in Nigeria (1970–2020)
Comparatively, recent inflation trends in Nigeria, specifically from 2013, have shown that there is no significant disparity in headline, rural and urban inflation. Though inflation appears to follow the same upward trend in both urban and rural areas, it is lower in rural region compared to the urban. This is due to the differences in lifestyle and consumption pattern between the two regions. This suggests that inflation in Nigeria is a macroeconomic challenge whose brunt is borne by all citizens regardless of location. Hence the need for more empirical studies to bring this phenomenon to a level that is economically sustainable and politically acceptable. More information in Fig. 4.
Fig. 4.
Inflation—headline, urban and rural
The importance of applying ML to Nigeria’s inflation data at both economic and statistical standpoint cannot be overemphasized. From the economic perspective, ML provides a pathway to where policy about inflation control should be directed. Although, all inflation studies conducted in Nigeria used macroeconomic variables and most of the studies excluded CPI components. This approach will undermine the main component of CPI basket that drives inflation. From statistical standpoint, many econometric models that include inflation studies in Nigeria suffer from ‘curse dimensionality’ problem, a statistical problem that emanates from organizing and analyzing data in high-dimensional-spaces. This problem limits the forecast ability of many of the extant models, this is because information extracted from the few predictors may not be sufficient to forecast inflation at a higher level of accuracy. Therefore, ML algorithms offer the flexibility of fine-tuning predictor parameters in the event of model overfitting. This flexibility enriches ML models and enhances the sophistication of providing a better statistical relevance to the existing tools of analysis in Nigeria. In addition, ML approach is not entirely a standalone algorithm, as other time series model might be, it offers many options where models can be stacked or unstacked.
Methods
Consider the following forecasting model,
| 1 |
where is the variable at time , is vector of explanatory variables, is a difference process of martingale. The objective is to estimate the target function . The model and forecast performance are to assess the predictive accuracy through a loss function. The loss function is estimated using the Root Mean Square Error(RMSE) and it is calculated thus,
| 2 |
The objective here is to minimize the square error. Though other reported loss functions for base learners include Mean Squared Error (MSE), Mean Absolute Error (MSE) and Root Mean Square Logarithmic Error (RMSLE), the RMSE remains the commonly used loss function for both classification and regression models. We compare the traditional inflation model, Autoregression Integrated Moving Average (ARIMA) as a baseline model4, with other base learners.
Predictions are obtained from the test data and the prediction from the training data are used to check for model overfitting and performance.
ARIMA model
ARIMA is a univariate model that is fitted with Box-Jenkins method and it is specified by three order parameters(p, d, q). p is the Auto-Regressive (AR) parameter that indicates the number of lags to include in the model. The equation below follows AR(2) process;
| 3 |
Where is time series, and are coefficients of the AR terms in period one and two. The d component is the degree of differencing that is integrated in the order (I(d)). It is used for stabilizing data when the assumption of stationarity fails. In other words, it also represents the number of times a time series must be differenced to induce stationarity. The q component is the Moving Average (MA) that makes up the non-seasonal aspect of ARIMA model. The MA(q) represents the combination of the previous error terms of the model. q is the order of previous error term to include in the model. The example of MA(2) is given below,
| 4 |
Where and are coefficients of the MA terms in period one and two. Therefore, the main ARIMA model is given by combining equation 3.3 and 3.4. The time series is stationary if else ARIMA(p,d,q) reduces to ARMA(p,q)
| 5 |
This study uses Akaike Information Criterion(AIC) and Bayesian Information Criterion (BIC) for model selection. The two criteria is conjecture on the extent to which the fitted values approximates the true value of the model. Furthermore, AIC and BIC are statistic functions that penalise the goodness of fit used in estimating the statistical model. This penalty prevents model overfitting however, as the number of estimated parameters increase, the penalty increases.
Ensemble models-base learners
In this study, we adopt three relevant base learners in our ensemble catalogue, namely, Random Forest (RF), Gradient Boosting Machines (GBMs) and Generalized Linear Models (GLM). New predictions are made by combining the predictions from the individual base models that make up the ensemble. RF and GBM are all ensemble models because each uses decision trees as its base-learner. While RF is applicable where data has high variance and low bias, GBM is useful where there is low variance and high bias. Hence, the strength of one ensemble is the weakness of the other and vice-versa.
- Random Forest (RF): RF is based on an algorithm in which decision trees are bootstrapped on the original training data then, new data are formed and new predictions are made by averaging all predicted values from the decision trees5. Constructing decision trees in stages help to divide the entire sample space by breaking a quality function Q(X, 1, p), into two sub-samples. The first sample is given as while the second sample is given as . Each sub-sample is therefore, broken down iteratively and stops when individual criterion is specified and n leaf corresponding to each to each sub-sample is created (Baybuza 2018). While the tree holds the regression solutions that breaks down the sub-sample into two, the leaf nodes hold the quality function, which is the predicated values of the explanatory variables. The quality function is given below;
Where H(X) is the information criterion and it explains homogeneity of the explanatory variables in the sub-sample. According to Baybuza (2018), The purpose is to maximize the homogeneous characteristics of the explanatory variables while minimizing the spread prevalent in the explanatory variables so that;6
Along this process, RF6 is not only capable of reducing variance and minimize overfitting but its ability to introduce a more random component into the tree building process gives the result of the ensemble model a robust predictive performance.7
For example we can fit independent weak learners, one for each sub-sample;
| 8 |
and then aggregate them into some kind of averaging process to get an ensemble model with a lower variance. For example, we can define our strong model such that
| 9 |
Important variable are identified and measured based on the sum of the reduction in the loss function (e.g., SSE) attributed to each variable at each split in a given tree. Therefore, for bagged decision trees, we compute the sum of the reduction of the loss function across all splits and then aggregate this measure across all trees for each feature(variable). The features with the largest average decrease in loss functions are considered most important (Fisher et al. 2018). The important driver for each of our response variable in RF is identified through a permutation-based (PB). Permutation approach captures the most important explanatory variable. This is obtained by calculating the increase in the model’s prediction error after permuting the variable (Bradley and Brandon 2020). In the PB7 approach (seeBradley and Brandon 2020 for more detail on permutation), the out-of-the bag(OOB) sample for each tree is passed down the tree and the prediction accuracy is obtained, the values of each explanatory variable are randomly permuted and the accuracy is again computed. Due to random shuffling of explanatory values, there is a decrease in the level of accuracy; this decrease is then averaged over all trees for each explanatory variable. The explanatory variable with the largest average decrease in accuracy is considered most important (Bradley and Brandon 2020; Breiman 2001).
To increase the predictive strength and avoid tree correlation and many noisy predictors, we increase the hyperparameter8, , and number of tree, ntree, to 1000 each while we decrease the tree depth to maximum of 30 and also use 10-fold cross validation for the RF.
-
2.Gradient Boosting Machines (GBMs): GBMs, which was first proposed by Friedman (2000), build an ensemble of shallow trees in sequence with the aim of learning each tree and improving on the previous errors. The shallow trees are weak learners and thus, produce weak predictions but they can be “boosted” to produce a strong and powerful ensemble models(Bradley and Brandon 2020). Recall that new predictions are made by combining the predictions from the individual base models that make up the ensemble (e.g., by averaging in regression). Because RF is more effectively applicable to models with high variance and low bias, averaging prediction across decision trees (as in RF), reduces variance of models while boosting work effectively on models with high bias and low variance (Greenwell et al. 2018). In addition, while RF trained the base models independently, GBMs do not. Baybuza (2018) describes the algorithm as follows;
- The first model is trained on the 100% of the sample such that;
10 - The ensemble GBM algorithm leads to the first trained base ensemble
11 - The residuals, which is the difference between the actual value and the predicted value based on the first GBM model are then calculated, such that
12 - The model below is then trained on the residuals
13 - We also add a new model to the previous algorithm using a ‘step reduction’ relating to a certain co-efficient . This method improves the model and avoids model overfitting and a new model is obtained;
14 - We run the process iteratively until the final model, which is given below, is produced.
The training cycles are completed when the algorithm terminates and the variable of importance measure are obtained in similar procedure as RF.15
Unlike RF, our GBM was trained with , maximum depth9 of 3, minimum rows of 5, learning rate10 of 0.01, and 10-fold cross validation.
-
3.Generalized Linear Models (GLM): The basic idea behind GLM estimation is to fit a regression model such that the predicted probability, , of our response variable is close as much as possible to the probability of response variable being observed. To yield an estimate equivalent to ordinary linear regression normal, we use “, which assumes an errors to be distributed normally. This idea can be fully formalized in a “likelihood function” as follows;
The estimates, and are chosen to maximize this likelihood function and the resulting estimates are the predicted probability of the response variable.16
Once our regression model is identified we then interpret how the features are influencing the results. Our variable of importance is determined by the magnitude of absolute value of the for each coefficient, which is similar in structure to random forest.
Stacked ensemble
Methods based on RF still have significant bias error problems while method based on GBM have variance issues. Hence, stacking these ensembles tend to solve the variance-bias trade off prevalent in machine learning. Stacking involves training a new learning algorithm to combine the predictions of several base learners. First, the base learners are trained using the available training data, then a combiner or meta algorithm, called the super learner, is trained to make a final prediction based on the predictions of the base learners. Super learners will learn an optimal combination of the base learner predictions and will typically perform as well as or better than any of the individual models that make up the stacked ensemble (Bradley and Brandon 2020).
The algorithm is simple but it evolves in three phases;
- Set up the ensemble
- Specify a list of base learners
- Specify a meta learning algorithm
- Train the ensemble
- Train each of the base learners on the training set.
- Perform k-fold cross validation (CV) on each of the base learners and collect the cross-validated predictions from each.
- The CV predicted values from each of the algorithms can be combined to form a new feature matrix
Where are the predicted values, is the Z, and y is the response vector.17 - Train the meta learning algorithm on . The “ensemble model” consists of the base learning models and the meta learning model, which can then be used to generate predictions on new data.
- Predict on new data
- To generate ensemble predictions, first generate predictions from the base learners.
- Feed those predictions into the meta learner to generate the ensemble prediction.
- Variable of importance for stacked ensemble: The novel contribution of this study is that it uses permute approach to measure the feature of importance of the meta learner from stacked ensemble. To the best of our knowledge, this is the first study that measure feature of importance directly from the stacked ensemble. After stacking the base learners and selecting the meta learner for the stacked ensemble, we compute the variable of importance score by calculating the percentage increase in the model’s prediction error after feature permutation. We follow the traditional permutation approach of base learners as described in Bradley and Brandon (2020). Following the usual performance degradation for permuting the training data set, we use the difference between the RMSE and the measure obtained after permuting the values of a specific feature in the training data set. The permutation-based variable/feature of importance algorithms for the feature set as hand is derived below;
-
ICompute the RMSE loss function in Eq. (2)
-
IIfor variable in the training data set i in do the following
- randomize the training data set
- apply the stacked ensemble model
- estimate RMSE or any loss function
- simulate the model using a fraction of the training data set
-
IIIset the prediction metrics
-
IVcompute the feature importance by obtaining the difference between the permuted loss and the original loss.
-
VSort variable in descending order.
-
I
Data description
We use monthly CPI data from June 2010 to April 2020 and then convert it into machine learning data interface which then results in 119 observations. Data was obtained from Nigeria Bureau of Statistics and it was filtered and sub-grouped into headline (Headline), headline less farm produce (core 1), headline less farm produce and energy (core 2). We also grouped our data into urban and rural inflation. The headline, urban, and rural inflation components have 61 variables each, core inflation has 57 variables, and core 2 has 52 variables. We incorporate the h2o object in cloud computing from R data frame into this study to make our ensemble models algorithms more flexible and seamless for prediction. It is common to use ensemble models to forecast inflation with the test data by selecting a forecast range date but we believe that there is a tendency for some data within certain date range to be influenced by external factors and thus, yields the same pattern. For instance, some data in the test data frame within certain date range might fall under recession, consequently, predicting such data may be similar and they are more likely than not yield the same pattern. In our study, we use a split command that randomly selects 70% of the sample as the training data and the remaining 30% as the test data. So, the idea is to predict a randomly selected test data, doing so will eliminate any issues that may likely arise from arbitrarily selecting range of dates for test data. By tradition, in macroeconomic models, variables are transformed into stationary series, in the event that they are non stationary, to avoid spurious results. However, latest study by Baybuza (2018) shows that transformed variables performed poorly for machine learning methods especially, the RF ensemble model. Hence, We follow the same procedure as (Baybuza 2018).
Results
In this section we present our main results for inflation using the CPI data. The first subsection fields the baseline results of the ARIMA model. The time series nature off all the inflation components are capture in this sections. The results include the drift parameters of all the inflation subgroups. The second subsection presents the performance of the base learners and the baseline model. These include analysis of different loss functions for training data set and cross-validation for different base learners and selection of a meta learner for training the stacked ensemble model. The third subsection presents the model performance and predict inflation subgroups. The last subsection deals with variable selection and variable importance for stacked ensemble model. We did this by identifying specific drivers of inflation components and make prediction afterwards.
The baseline results
The results of the ARIMA model is presented in Table 1 below. The results suggest that headline inflation dampens the trend in linear exponential smoothing. This is because the drift parameters has one autoregressive term, two seasonal differences that renders the Headline inflation nonstationary, and one lagged forecast errors in predicting the equation. The headline inflation is also the only feature in the suit of inflation components with only autoregressive term. However, all other components require linear exponential smoothing because they require two differencing to render inflation variable stationary. Similar to headline inflation, other inflation components have one lagged forecast errors for prediction. In a nutshell, headline inflation is different from other components inflation due to its autoregressive term.
Table 1.
The baseline model
| Headline | CORE 1 | CORE 2 | URBAN | RURAL | |
|---|---|---|---|---|---|
| Drift | (1,2,1) | (0,2,1) | (0,2,1) | (0,2,1) | (0,2,1) |
| AR(1) | 0.2907 | – | – | – | – |
| MA(1) | − 0.8995 | − 0.8793 | − 0.8904 | − 0.8719 | − 0.8937 |
| 1.916 | 2.262 | 2.609 | 3.269 | 2.819 | |
| AIC | 315.56 | 329.67 | 321.83 | 334.26 | 322.26 |
| BIC | 323.03 | 334.65 | 326.81 | 339.07 | 327.08 |
| log-likelihood | − 154.78 | − 162.84 | − 158.92 | − 165.13 | − 159.13 |
The variance of the inflation components are also reported. The results show that headline inflation is less volatile than other components while urban inflation is more persistent than other components.
Performance of the base learner models versus ARIMA
In table 2, we present two loss functions namely; MSE and RMSE for each base learners of our training data set in Table 2 and cross validation11 (see Table 4 in Appendix A for details). Building 1000 trees, with maximum depth of 30 and maximum tries of 10, on 119 observations (see Table 8 in Appendix C for details) with more than 50 predictors, RF appears to have a lower accuracy on the training data when compared with other base learners and and the baseline model. Unlike RF, GLM appears to have a better accuracy than all the base learners and the baseline model. However, we cannot conclude so at this point, since generalization on test data has not been made yet. Since the predictors represent about 40% of the observations, the likelihood of high variation or noisy predictors could have been responsible for accuracy distinctions across base learners. For detail analysis, we built a shallow model with lower trees and lower depth and also adopt a hyperparameter tuning strategy through a grid search, the results did not seems different from our initial experiment without grid search. In our case, higher RMSE in RF or any of the base learners for the training data should not pose a problem, since all the base learners are communed into stack ensemble model and the performance of the stacked model is what matters in the end.
Table 2.
Different loss functions for base learners and ARIMA model-training data
| Headline | Core 1 | Core 2 | Urban | Rural | ||
|---|---|---|---|---|---|---|
| Random Forest | MSE | 8.3955 | 5.8182 | 5.5240 | 8.2512 | 6.9754 |
| RMSE | 2.8975 | 2.4121 | 2.3503 | 2.8725 | 2.6411 | |
| GBM | MSE | 2.6738 | 2.1448 | 1.8429 | 3.4532 | 2.9332 |
| RMSE | 1.6352 | 1.4645 | 1.3575 | 1.8583 | 1.7127 | |
| GLM | MSE | 0.0010 | 0.0333 | 0.0900 | 0.0019 | 0.0019 |
| RMSE | 0.0324 | 0.1826 | 0.3000 | 0.0441 | 0.0433 | |
| ARIMA (Baseline) | MSE | 1.8322 | 2.1871 | 2.000 | 3.1524 | 2.7179 |
| RMSE | 1.3536 | 1.4789 | 1.4144 | 1.7755 | 1.6486 |
Our study further shows that GLM outperforms GBM, RF and the baseline model for all the inflation components; Headline, core 1, core 2, urban, and rural. Our baseline model clearly outperforms GBM in Headline inflation, urban, and rural inflation while GBM has more accuracy than baseline in core 1 and core 2 inflation. A lower RMSE on the training data set for GLM and GBM does not imply that the two base learners generalize on our data pretty well, since we have not yet evaluated each on the test data12. However, this is the first stage of selecting the best meta learner to train the stacked ensemble. Thus, a higher loss functions are not a threat or a problem at the moment and a lower loss functions are not considered perfect as well. We retain RMSE as the sole loss function for this study because it is the most widely use for model evaluation and model predictions.
Although the RMSE of RF is higher than other base learners for training data set in Table 2, we realized that it generalizes better on the test data reported in Appendix A. since the RMSE of its test data is almost the same as the RMSE of its training data set. Whereas, the baseline model clearly overfits in all the inflation components. The performance of the GBM is also not too bad as it generalizes well also on the test data set, especially the performance of GBM on core 2. Though, GLM yielded lower RMSE on the training data set, it does not generalizes well on the test data on all the inflation subgroups in fact, it conspicuously suffers from marginal over-fitting although, it does not pose a serious concern for our stacked ensemble model since the staked ensemble will need to generate its own RMSE that is independent of base learner RMSE. So, obtaining lower RMSE on training data set only for any base learner will not suffice to conclude that it has a higher predictive power or perform well than others except we evaluates such models on the test data. This is the second stage of selecting our meta learner to train the stacked ensemble. The baseline model clearly suffers from overfitting problem despite auto selecting the parameters. The results show that the inflation series is not all linear thus, needs some exponential smoothing.
The results in Table 2 reveals one of the best ways to choose the most performing model for forecasting, these results are obtained from the training data set (in-sample). However, Table 3 depicts the validation results, the test (out-of-sample) CPI data of the stacked ensemble and the ARIMA models. The stacked ensemble model did not only generalizes well on the test data but also outperform the baseline model13. We stacked the ensemble model, using each base learner as a meta learner. In addition, the performance of the models reveal that
Table 3.
Model validation of ARIMA and the stacked ensemble
| Meta learner | Headline | Core 1 | Core 2 | Urban | Rural | |
|---|---|---|---|---|---|---|
| Stacked Ensemble () | 0.94 | 0.91 | 0.93 | 0.92 | 0.89 | |
| Random Forest | 2.69 | 2.30 | 2.08 | 3.61 | 3.39 | |
| GBM | 4.06 | 2.52 | 2.48 | 3.52 | 3.31 | |
| GLM | 2.64 | 2.41 | 2.23 | 2.79 | 2.58 | |
| ARIMA | 6.30 | 4.81 | 4.42 | 8.58 | 7.95 |
The RMSE are standardized for all our ensembles, the meta learner with the lowest RMSE across the inflation components are chosen for meta learner for our stacked ensemble model. RF as a meta learner performs better than GBM and GLM for headline, core 1, and rural inflation. Whereas, GLM performs better than other base learners for core 2 and urban inflation if it is used as the meta learner for the stacked ensemble model. The model with the lowest bias14 as a meta learner are trained on the stacked ensemble and consequently used in predicting and selecting inflation drivers. The coefficient of determination of our models validates the superiority of stacked ensemble over the ARIMA model. The of the inflation components, out-of-sample, are at least , hence, the stacked ensemble significantly out perform the ARIMA model both in evaluation, validation, and in performance.
The model performance and prediction of inflation components
The stacked ensemble results presented in table 4 a uses RMSE as the basis for model performance. when we trained the stacked ensemble model with RF, the model performs better on CPI data for headline, core 1, and rural inflation while GLM outperforms other base learners in core 2 and urban inflation. The model prediction and the selection of most important driver, using the test data, for each inflation subgroup absolutely yields the same result when we switched RF for GLM as a meta learner for the stacked ensemble model core 2 inflation. The predictive accuracy of the stacked ensemble on training and test data for all inflation subgroups is presented in Appendix B (Fig. 5).
Fig. 5.
Model performance actual vs predicted
When we trained each base learner as a meta learner for our stacked ensemble, the RMSEs were standardized and that process changed the potential model selection for our predictions. RF becomes potentially accurate for all inflation subgroups when we generalize it on the test data, except for core 2 and urban inflation. But, criteria for selecting a trained meta learner for stacked ensemble is not limited to how small the RMSE of the training data of each model is, but how well the training data predicts the subgroup inflation. The predicted values of the training inflation data tracks the actual inflation data pretty well. This is not surprising since the stacked ensemble model is trained on the same data thus, predicting its value may not be an issue. But the model did not generalize well on the predicted value of the training data when we trained stacked model using the GBM as a meta learner. This is because the bias of GBM is higher than other base learners when used as a meta learner for the stacked ensemble.
A trained model does not suffer from model overfits15 if it generalizes well on the test data. Using the stacked ensemble models for predicting and forecasting inflation (see Figure 10 in Appendix B for details), the predicted test data fits the actual CPI data of all the inflation subgroups very well. This is because our strategy of selecting the meta learner to train our stacked ensemble model works perfectly. This strategy yields a smaller RMSE of the test data for almost all our ensemble models across the subgroup inflation. Thus, suggesting that stacked model is more accurate for predicting inflation in Nigeria than a standalone model, as it is common in econometric analysis. The jumps might be due to a smaller randomly selected sample; as mentioned earlier, we performed a random split of for training data and were randomly allocated to test data consequently, the predicted and actual test data may not converge well. But this is not a concern at this point.
Variable of importance using stacked ensemble
The main idea of this section is to use our stacked ensemble model to select the most important predictors, which are the main drivers, for the inflation components. To do this, we first trained a new learning algorithm that combine all the inflation predictors of the base learners then, a meta algorithm, also known as super learner, is trained with of the CPI data to make a selection of the most important variable. This way, the stacked ensemble models outperforms individual base learners and has proved to asymptotically create an optimal system for learning (see Laan et al. 2003). The stacked ensemble whose trained meta learner yields the best performance and generalizes well on the test data is use for selecting important inflation subgroup drivers and for prediction. Consequently, we use RF to select important drivers of headline, core 1, and urban inflation and use GLM to select important driver of core 2 and rural inflation, this is because the meta learner for the stacked model has the lowest bias.
We identified ten most important predictors in each subgroups however, some of the components of the inflation subgroups also have subcomponents. For instance, food as a component also have about nine subcomponents which are also predictors for food inflation. As part of the inflation drivers, food is the most important driver for headline, urban, and rural inflation. This is not surprising because food has the highest weight, , in the inflation baskets in Nigeria. Moreover, research has shown that households spend more than of their income on food therefore, it is not surprising for our stacked algorithms to identified it as the most important driver. Our modeling does not include the weight of the predictors but the stacked model was able to identify food as the most important driver because it recognizes the pattern of food CPI is more sensitive to income changes when compared with other predictors, implying that policy may have huge implication for household spending. While electricity is the fifth most important driver for headline inflation, it is the eighth most important driver for rural inflation. Electricity is an issue in Nigeria and its inability to come up as one of the first-tenth most important driver in urban inflation is not surprising. Majority of the urban households and firms already created alternative source of energy but such alternatives are not common in rural areas therefore, spending on electricity will be more sensitive to inflation in the rural areas in Nigeria. Air transportation is the second most important driver for Headline and urban inflation but the most important driver for core 1 inflation. Fuels and lubricants for personal transport equipment is the fourth most important driver for headline, fifth most important driver for rural inflation, and sixth most important driver for core 1 inflation. After excluding all farm produce and energy from headline, carpets and flooring become the most important driver for core 2 inflation and medical services appears as the most second important driver. So, changes in income spending on carpets and flooring and medical services can cause changes in CPI in Nigeria.
Having identified food as the most important driver for headline inflation, we examine the nine components16 (see Table 9 in Appendix G for details ) and identify the component that is important in driving food inflation. So, we use our stacked ensemble algorithm to select the most important driver of food inflation and predict same using the test data. Figure 6 shows the most important driver of food inflation.
Fig. 6.
Variable of importance for food
From the above figure, bread and cereals is the most important variable17, vegetables as the second most important driver, and meat as the third. However, fish is the last most important driver of food inflation. This is also not surprising, among the components of food inflation bread and cereals has the highest weight and this weight is out of of the food inflation from headline inflation. This result implies that the total household expenditure on bread and cereals is almost half of total expenditure on food. The low weight of vegetables among the classes or components food inflation, is about out of of the food inflation, does not pose a barrier for its position as one of the leading drivers in food inflation. The implication of the results is that vegetables may not occupy a large proportion of the household expenditures but changes in household consumption may help policy makers understand and control food inflation. Potatoes,Yam & Other Tubers are the component of food inflation with the highest weight after bread and cereals but it is the fourth most important food driver. So, despite their relatively larger share of household expenditure on food, they are not as important to drive inflation as meat and vegetables in Nigeria. Household income on fish should not pose a serious concern for controlling food inflation, since they are the least important driver for food inflation.
We present the performance of the stacked ensemble for food inflation in Fig. 7. The Figure shows the predicted CPI for training and test data.
Fig. 7.
Food CPI
Figure 7a depicts the actual training CPI and the predicted CPI data. The performance is not surprising since it was the data that was used to train our model however, it will help to explain whether the predicted CPI data in Fig. 7b have similar pattern with the CPI for the training data. We could therefore, conclude that our actual CPI data generalizes well on the predicted CPI of the test data. The model performed poorly when meta learner was switched to GBM and RF.
Bread and cereals in food inflation component have twenty-three subcomponents for food inflation. Therefore, the main goal is to identify the most important driver of bread and cereals inflation by following the same procedure as food inflation. We start with the stacked ensemble model results for each meta learner, these results are in depicted in Table 6. The results show that RF clearly overfits while GBM and GLM generalizes well on test data but GLM is better because of its lower bias therefore, we selected GLM as our meta learner. As usual, we trained GBM as the main meta learner but its performance is not as good as performance of GLM. The ten most important driver for bread and cereal inflation is depicted in Fig. 8, and the prediction of training and test CPI data is available in Fig. 9.
Fig. 8.
Variable of importance for bread and cereals
Fig. 9.
Bread and cereals CPI
The foremost driver of bread and cereal inflation is biscuits and the second most important driver is sausage. Rice agric is the third most important driver but it is the component of bread cereal inflation with the highest weight; out of weight of bread cereals in food inflation, rice and agric shares . However, cabin biscuits has weights out of the total weight of bread and cereal inflation. By weight, rice agric, garri yellow, rice local, maize grain, millet, and sorghum are the six most important predictors, their individual weight is at least more than , but only rice agric and millet are in the tenth most important drivers of bread and cereals inflation. In addition, components that are too low by weights mostly drive cereal and bread inflation. This suggests that changes in households expenditure allocated to components of bread and cereals which has a lower weights can pose a threat to inflation management in Nigeria. Unfortunately, lack of monetary target, in the medium-term, of these food subcomponents might have been responsible as to why food inflation has been difficult for monetary authority to control; if these items have a lower weights but are important drivers of the food subcomponents inflation then, it is possible that government might have ignored its impact on headline inflation due to its negligible weights.
Cabin biscuit, rice agric, garri white, and semovita turnout as the topmost driver of bread and cereals, Bread and cereal is the main food inflation driver, while food inflation is the main headline, urban, and rural inflation driver. Moreover, air transportation, household textile, liquid fuels also top the ten most important driver in core 1 inflation while carpets and flooring, which has about in the entire inflation weight, are the main driver in core 2 inflation. Some of the components may have lower weights but they are very significant in driving inflation in Nigeria. In fact, the performance of our model is very robust in capturing the predicted bread and cereals CPI data pretty well. Figure 9a shows the actual and predicted CPI for bread and cereal using the training sample while Fig. 9b reveals the actual and predicted CPI for bread and cereals using the test data.
The two figures are similar and it shows that our stacked ensemble has a predictive ability over standalone model. This is because when we randomly split the data, the stacked ensemble model predicts and forecasts the randomly selected test data accurately. Doing so, attests to the better predictive performance of the stacked ensemble model.
Forecast horizons of selected inflation variables of our model is depicted in appendix C. The RMSE forecast from the first to ninth horizon is below 9.5 but a 1.7 point jump from 8.8 in ninth horizon to 10.5 in tenth horizon is noticeable. However, the forecast was fairly stable starting from from twentieth horizon.
Conclusion and policy recommendation
We examined the performance of stacked ensemble model by identifying the inflation drivers in Nigeria. To our knowledge, this is the first study that utilized stacked ensemble to identify and analyse inflation drivers for any country. The stacked ensemble approached was used to identify the variable of importance that is stable across the predicting horizons. The evidence suggests that the main driver of inflation in Nigeria is Food inflation. Of the components of food inflation, we identified Bread and cereal, vegetables and meat as the main drivers of food inflation. The components of bread and cereal were analysed further as the top driver of food inflation; biscuits, agric rice and garri white were the main drivers of inflation in bread and cereal.18.
Shifting focus from headline to food inflation subcomponents, such as bread and cereal, to understand inflation drivers reveal a piece-wise information that may not otherwise be available if the price indices are not disaggregated. The argument about the significance of “food prices” in driving headline inflation is an evidence of a larger proportion of households disposable income allocated to food items. With so much spending on food, the CPI of headline, urban, and rural inflation will continue to rise. The high cost of imported capital goods for manufacturing 800g of cabin biscuits pack and sausage beef is a narrative indicative of cost-push inflation. The higher cost automatically disrupts the supply chain of cabin biscuits and sausage beef and thus, renders the two food items as the most food CPI drivers. However, the price of “rice agric sold loose” and “garri white sold loose” are main drivers of food prices. A high disposable income of households competing for these two staple foods items can lead to a demand-pull inflation in Nigeria.
This study has also proved the flexibility and viability of ML algorithms in predicting Nigerian inflation. As evidenced from our results, each base learner were trained as a meta learner for our stacked ensemble. The results of which identified “RF” as the best performing meta learner for training the stack ensemble model. Since some of the inflation subgroups are best predicted with “RF”. It thus, suggests that some inflation data are best predicted with nonlinear models. Recent advances in ML methods can improve forecasts where the target variable can be explained by many predictors and more than two-dimensional space. In this regards, stacked ensemble deserves a special attention as it has the potency of compensating the weakness of a base learner with the strength of another base learner. Consequently, the synergistic performance of stacking each base learner produces a formidable model that yields the highest level of accuracy and best predictive ability. In our study, we analyzed the test data, out-of-sample, and our results show a strong accuracy in predicting inflation, as the time horizon increases, contrary to recent studies (seeMedeiros et al. (2019)), the accuracy of our model in predicting out-of-sample data did not diminish. In addition, volatility problems do not constrain nor affect the prediction. The more volatile and the less volatile inflation subgroups, such as “core 1” and “core 2”, were all predicted with high accuracy.
Adequate trace of the source of inflation to the least component of each subgroups will help design an appropriate policy in addressing inflation problems. Moreover, some of the CPI items that mostly drives inflation have lower weights19 while others have higher weights. Therefore, focusing entirely on CPI weights as a policy guide will stymied a successful control of inflation in Nigeria. However, establishing the relationship between the persistence of food inflation and central bank credibility using stacked ensemble would be an interesting area to explore further.
Supplementary Information
Below is the link to the electronic supplementary material.
Author contributions
EmA write-up the methodology, results and analyses, and the conclusion. ElA and OT jointly did the introduction and literature review sections while JJ and AA collect the data and prepare it for use.
Funding
There is no funding sources.
Data availability
The data that support the findings of this study are available from the corresponding author upon reasonable request.
The views expressed in this paper are those of the authors, and do not necessarily reflect the views of anyone else affiliated with the Central Bank of Nigeria and CAPE Economic Research and Consulting. Any correspondence should therefore, be shared through the emails provided.
Declarations
Conflict of interest
The authors declare that there is no conflict of interest.
Ethical approval
This article does not contain any studies with human participants or animals performed by any of the authors.
Footnotes
A potentially large number of predictors with a small number of observations is what Stock and Watson (2011) referred to as ‘curse of dimensionality’.
Figure 1 is the plot of Core 1 inflation. The fluctuation of core 1 inflation in Nigeria is due to the components included in the basket of its computation. National Bureau of Statistics (NBS) does not exclude energy prices such as premium motor spirit (PMS), gas, and utility prices. In addition, the high exchange rate market pressure has also contributed significantly to the fluctuation of prices of many of the items in the core basket. This is because the Nigerian economy is highly import dependent and many of the item in core 1 basket are also imported.
See Fig. 2 for inflation trend in Nigeria from January to August 2020.
Some of these univariate models such as Autoregression Moving Average (ARMA) and UNobserved Components and a Stochastic Volatility (UC-SV) model has been found to be less accurate and less robust when compared with machine learning ensemble models (see Baybuza 2018; Coulombe et al. 2019; Medeiros et al. 2019 for details).
The main idea is to minimize the sum of the weighted average variance within the resulting sub-samples (Bradley and Brandon 2020). Using the tree constructed, we can predict values for the target variables with the newly created values of the explanatory variables. The decision tree models allow us to create an effective nonlinear dependence by minimizing the variance target variable.
In other words, random forests are modification to bagged decision trees that build a large collection of de-correlated trees to further improve predictive performance (Breiman 2001).
Permuting the value of an important explanatory variable in the training data will degrade the training performance of model. This is because a permuted variable will reduce the relationship between and explanatory variables and the response variable (target variable). The approach uses the difference between some baseline performance, such as Root Mean Squared Error (RMSE) and the performance measure obtained after permuting the values of a a particular explanatory variable in the training data set. In other words, an explanatory variable is “important” in driving a response variable if permuting its values increase the chances of higher model error relative to the other explanatory variables, since the model relied on the important variable for its prediction. Whereas an explanatory variable is ’least important” if permuting its values render the model error relatively unchanged, since the model did not recognize the explanatory variable for the prediction.
The parameter that controls the split-randomization of the explanatory variables; Segal (2004) showed that data with many noisy predictors can have an improved performance if the is higher.
Values range between . A higher depth allow the model to capture specific interactions but increase the chances of over-fitting while a smaller depth is computationally efficient and may avoid over-fitting.
Evaluates the impact of each tree on the final outcome. It also controls the speed at which the algorithm proceeds down the gradient descent or learns.
The process involve splitting the training data set into two parts
The exclusion of food and farm produce from headline inflation, core 1, and exclusion of food, all farm produce, and energy from headline inflation, core 2, render core 1 and core 2 to be less volatile than headline inflation.
The results are consistent with Baybuza (2018); Coulombe et al. (2019), and Medeiros et al. (2019) studies.
see Table 4 in Appendix A for details, it is calculated as the difference between the RMSE of CPI using the training data and RMSE of the predicted CPI using the test data.
Although, the RMSE of the test data of RF in Table 4a is higher than the RMSE of the test data of GBM and GLM but RF seems to generalize better relatively because the RMSE of its test data of all inflation subgroups are much lower than RMSE of its training data.
Including Bread and cereals, meat, fish, milk, cheese and eggs as a subcomponent, oil and fats, as a subcomponent, fruits, vegetables, potatoes, yam, and other tubers as a subcomponent, and sugar jam etc as a subcomponent.
The importance variable parameters are the important predictors designed to determine the drivers. The derivations of different variable of importance of each algorithms are explained in Sect. Ensemble models-base learners.
We identified food as the main driver for headline, urban, and rural inflation thus, we analyze food inflation components to gain more insight into relevant drivers, while air transportation is the core 1 main driver, carpet and flooring is the main driver for core 2 inflation. Among the food components, “bread and cereals” are the main driver while “vegetables” is the second most important driver of food inflation. Cabin biscuits, a components of Bread and cereals CPI and subcomponent of food CPI, is the main inflation driver our stacked ensemble model was able to identified.
Ignoring such items in policy intervention will make inflation difficult to control; this problem is very crucial in food inflation.
Contributor Information
Emmanuel O. Akande, Email: eakande75@gmail.com
Elijah O. Akanni, Email: lijakan2000@gmail.com
Oyedamola F. Taiwo, Email: oyedamolataiwo@gmail.com
Jeremiah D. Joshua, Email: jdjoshua@cbn.gov.ng
Abel Anthony, Email: tonyabel387@gmail.com.
References
- Agnor P, Akindutire O, Ogunyemi J. Monetary policy and control of inflation in Nigeria. Int J Manage. 2018;8(12):154–170. [Google Scholar]
- Agnor P, Montiel P. Development Macroeconomics. Princeton, New Jersey: Princeton University Press; 1996. [Google Scholar]
- Akdogan K, Beser S, Chadwick M, Ertug D, Hulagu T, Kosem S, Ogunc F, Ozmem M, Tekalti N (2012) Short-term inflation forecasting models for turkey and a forecast combination analysis. Turkiye Cumhuriyet Merkez Bankasi Working Paper, 12(09)
- Amadi IU, Gideon WO, Nnoka LC. Time series models on Nigerian monthly inflation rate series. Int J Phys Chem Math Sci. 2013;2(2):124–128. [Google Scholar]
- Asekunowo V. The causes of persistent inflation in Nigeria. CBN J Appl Stat. 2016;7(2):49. [Google Scholar]
- Ashraf Q, Gershman B, Howitt P (2013) How inflation affects macroeconomic performance: an agent-based computational investigation. NBER Working Paper, p 18225
- Asogu J. An econometric analysis of the nature and causes of inflation in Nigeria. Central Bank of Nigeria Econ Fin Rev. 1991;29:19–30. [Google Scholar]
- Atkeson A, Ohanian L. Are Philips curves useful of forecasting inflation. Federal Reserve Bank of Minneapolis Quart Rev. 2001;25:2–11. [Google Scholar]
- Atuk O, Ozmen M. A new appropach to measuring core inflation for turkey:satrim. Iktisat Isletme ve Finans. 2009;24(285):73–88. [Google Scholar]
- Baybuza I. Inflation forecasting using machine learning methods. Russ J Money Fin. 2018;77(4):42–59. doi: 10.31477/rjmf.201804.42. [DOI] [Google Scholar]
- Bayo F. Determinants of inflation in Nigeria: an empirical analysis. Int J Human Soc Sci. 2011;1(18):262–271. [Google Scholar]
- Benalal NJL, Diaz de Hoyo B, Landau Roma M, Skudelny F (2004) To aggregate or not to aggregate? euro area inflation forecasting. ECB Working Paper series, 374
- Bjornland H, Gerdrup K, Jore A, Smith C, Thorsrud L (2009) Does forecast combination improve norges bank inflation forecasts? Economics Department, Working paper,
- Bradley B, Brandon G. Hands-On Machine Learning with R. Boca Raton, FL, USA: CRC Press; 2020. [Google Scholar]
- Breiman L. Random forests. Mach Learn. 2001;45(1):5–32. doi: 10.1023/A:1010933404324. [DOI] [Google Scholar]
- Brunner K, Meltzer A (1976) An aggregate theory for a closed economy, in Monetarism. J.Stein, Amsterdam, North-Holland
- Bryan M, Cecchetti S (1994) Measuring core inflation. NBER Working Paper, p 4303
- Bullard J (2011) President’s message: Headline vs. core inflation: a look at some issues. Federal Reserve Bank, Louis
- Capistran C, Constandse C, Ramos-Francia M. Multi-horizon inflation forecast using disaggregated data. Econ Model. 2010;27:666–677. doi: 10.1016/j.econmod.2010.01.006. [DOI] [Google Scholar]
- Capolongo A, Pacella C. Forecasting inflation in the euro area: countries matter! Empirical Econ. 2020;61(5):2477–2499. doi: 10.1007/s00181-020-01959-4. [DOI] [Google Scholar]
- Cecchetti G, Wiggins R (1997) Efficient inflation estimation. Federal Reserve Bank Cleveland Working Paper,p 9707
- Clark T, Doh T (2011) A Bayesian evaluation of alternative models of trend inflation. Working Paper
- Cogley T, Sbordone A. Trend inflation, indexation, and inflation persistence in the new keynesian phillips curve. Am Econ Rev. 2008;98:2101–26. doi: 10.1257/aer.98.5.2101. [DOI] [Google Scholar]
- Coulombe P, Leroux C, Stevanoic D, Surprenant S (2019) How is machine learning useful for macroeconomic forecasting? CIRANO Working Paper 10.1002/jae.2910.
- Crone T, Khettry N, Mester L, Novac J. Core measure of inflation as predictors of total inflation. J Money Credit and Banking. 2013;45(2–3):505–519. doi: 10.1111/jmcb.12013. [DOI] [Google Scholar]
- De-Graeve F, Emiris M, Wouters R. A structural decomposition of the us yield curve. J Monetary Econ. 2009;56:545–559. doi: 10.1016/j.jmoneco.2009.03.013. [DOI] [Google Scholar]
- Doguwa S. inflation and economic growth in Nigeria: detecting the threshold level. CBN J Appl Stat. 2012;3(2):99. [Google Scholar]
- Doguwa S, Alade S. Short-term inflation forecasting models for Nigeria. CBN J Appl Stat. 2013;4(2):1–29. [Google Scholar]
- Dotsey M, Fujita S, Stark T (2017) Do philips curve conditionally help to forecast inflation. Federal Reserve Bank of Philadephia, pp 17–26
- Fakiyesi O. Further empirical analysis of inflation in Nigeria. Central Bank Econ Rev. 1996;34:489–499. [Google Scholar]
- Faust J, Wright JH. Handbook of economic forecasting. Forecasting Inflation. 2013;2:3–56. [Google Scholar]
- Fawad Z, Abdul Q, Pervaiz G (2015) Forecasting inflation using functional time series analysis. MPRA Papers, p 67208
- Fisher A, Cynthia R, Francesca D (2018) Model class reliance: Variable importance measures for any machine learning model class, from the rashomon perspective. arXiv Preprint arXiv, 1801.01489
- Freeman D. Do core inflation measures help forecast inflation. Econ Lett. 1998;58:143–147. doi: 10.1016/S0165-1765(97)00257-7. [DOI] [Google Scholar]
- Friedman JH. Greedy function approximation: a gradient boosting machine. Ann Stat. 2000;29(5):1189–1232. [Google Scholar]
- Friedman M (1956) The Quantity Theory of Money- A Restatement. In Studies in The Quantity of Money. University of Chicago Press, Economic Research Center, University of Chicago
- Friedman M. The counter-revolution in monetary theory. Occasional Paper London: Institute of Economic Affairs; 1970. p. 33. [Google Scholar]
- Gaomab M (1998) Modelling inflation in Namibia. Bank of Namibia Occasional Papers
- Giannone D, Michele L, Daphne M. Short-term inflation projections: a Bayesian vector autoregressive approach. Int J Forecast. 2014;30(3):635–644. doi: 10.1016/j.ijforecast.2013.01.012. [DOI] [Google Scholar]
- Gonzales A, Hubrich K, Terasvirta T (2011) Forecasting inflation with gradual regime shifts and exogenous information. ECBWorking Paper, p 1363
- Gracia M, Medeiros M. Real-time inflation forecasting with high-dimensional models: the case of Brazil. Int J Forecast. 2017;33:673–679. [Google Scholar]
- Greenwell B, Boehmke B, Cunningham J, Developers G (2018) gbm: Generalized boosted regression models. R Package Version 2.1 4
- Greon J, Paap R, Ravazzolo F. Real-time inflation forecasting in a changing world. J Bus Econ Stat. 2013;31:29–44. doi: 10.1080/07350015.2012.727718. [DOI] [Google Scholar]
- Gu S, Kelly B, Xiu D (2018) Empirical asset pricing with machine learning. Working Paper, University of Chicago
- Gurkaynak S, Sack B, Swason E. The sensitivity of long-term interest rates to economic news: evidence and implications for macroeconomic models. Am Econ Rev. 2005;95:425–436. doi: 10.1257/0002828053828446. [DOI] [Google Scholar]
- Imimole B, Enoma A (2011) Exchange rate depreciation and inflation in Nigeria (1988-2011). Bus Econ J 2011
- Inoue A, Lutz K. How useful is bagging in forecasting economic time series? a case study of u.s. cpi inflation. J Am Stat Assoc. 2008;103:511–22. doi: 10.1198/016214507000000473. [DOI] [Google Scholar]
- Javed Z, Farooq M, Akram S. Cost-push shock and inflation: an empirical analysis from the economy of Pakistan. J Econ Int Fin. 2010;2(12):308–312. [Google Scholar]
- Junttila J, Korhonen M. Utilizing financial market information in forecasting real growth, inflation and real exchange rate. Int Rev Econ Fin. 2011;20(2):281–301. doi: 10.1016/j.iref.2010.06.006. [DOI] [Google Scholar]
- Kapetanios G, Marcellino M, Papailias F. Forecasting inflation and gdp growth using heuristic optimisation of information criteria and variable reduction methods. Comput Stat Data Anal. 2016;100:369–382. doi: 10.1016/j.csda.2015.02.017. [DOI] [Google Scholar]
- Kelikume I, Salami A. Time series modeling and forecasting information: evidence from Nigeria. Int J Bus Fin Res. 2014;8(2):41–51. [Google Scholar]
- Kirkpatrick C, Nixon F. Inflation and stabilization policies in ldcs. Basil Blackwell, Oxford: Surveys in development Economics; 1987. [Google Scholar]
- Krugman P, Persson T, Svensson L. Inflation, money velocity and welfare. Stockholm Sweden: Institute for International Economic Studies; 1982. [Google Scholar]
- Laan vD. Super learner. Stat Appl Genet Mol Biol. 2003;6:1. doi: 10.2202/1544-6115.1309. [DOI] [PubMed] [Google Scholar]
- Le Bihan H, Sedillot F. Do core inflation measures help forecast out-of-sample evidence from French data. Econ Latter. 2000;69(3):261–266. doi: 10.1016/S0165-1765(00)00307-4. [DOI] [Google Scholar]
- Malhotra A, Maloob M. Understanding food inflation in indi: a machine learning approach. Bombay, India: Indian Institute of Technology; 2017. [Google Scholar]
- Mbutor O. Inflation in Nigeria: how much is the function of money. J Econ Int Fin. 2013;6(1):21–27. doi: 10.5897/JEIF2013.0533. [DOI] [Google Scholar]
- Medeiros MC, Mendesy EF. Adaptive lasso estimation for ardl models with garch innovations. Econometr Rev. 2016;36:622–637. doi: 10.1080/07474938.2017.1307319. [DOI] [Google Scholar]
- Medeiros MC, Vasconcelos GFR, Veiga A, Zilberman E. Forecasting inflation in a data-rich environment: the benefits of machine learning methods. J Bus Econ Stat. 2019;39(1):98–119. doi: 10.1080/07350015.2019.1637745. [DOI] [Google Scholar]
- Meyler A, K G, Quinn T (1998) Forecasting irish inflation using arima models. Technical Paper Series, Central Bank and Financial Services Authority Ireland, 3/RT/98:1–48
- Miskin F (2007) Headline versus core inflation in the conduct of monetary policy. Montreal,Canada. Business Cycles International Transmission and Macroeconomic Policy Conference
- Moser G (1995) The main determinants of inflation in nigeria. IMF Staff Papers, p 42
- Nse S, Udoh N, Isaiah A. A predictive model of inflation in Nigeria. J Appl Stat. 2018;9(2):103–129. [Google Scholar]
- Odo A, Odionye J, Ojike R (2016) Inflation dynamics in Nigeria: implication for monetary policy response. J Econ Sustainable Dev 7(8)
- Odusanya I, Atanda A. Analysis of inflation and its determinants in Nigeria. Pakistan J Soc Sci. 2010;7(2):97–100. doi: 10.3923/pjssci.2010.97.100. [DOI] [Google Scholar]
- Okafor C, Shaibu I. Application of arima models to Nigerian inflation dynamics. Res J Fin Account. 2013;4(3):138–150. [Google Scholar]
- Olubusoye O, Oyaromade R (2008) Modelling the inflation process in Nigeria. African Economic Research Consortium (AERC), p 182
- Omekara C, Ekpenyong E, Ekerete M. Modeling the Nigeria inflation rates using periodogram and Fourier series analysis. CBN J Appl Stat. 2013;4(2):51–68. [Google Scholar]
- Onimode B, Alhassan J, Adepoju S. Comparative study of inflation rates forecasting using feed-forward artificial neural networks and auto-regressive (ar) models. Int J Comput Sci Issues. 2015;12(2):260–266. [Google Scholar]
- Oren B, Jonathan B, Itamar C, Allon H, K., N. (2021). Forecasting cpi inflation components with hierarchical recurrent neural networks. Available at: https://scholar.harvard.edu/files/jbenchimol/files/forecasting-cpi-inflation-components-hrnn.pdf
- Parking M. Inflation: a survey. Econ J. 1975;85(340):741–809. doi: 10.2307/2230624. [DOI] [Google Scholar]
- Pincheira P, Selaive J, Nolazco J (2016) The evasive ability of core inflation. BBVA Working Paper, 15/34 BBVA Bank, Economic Research Department
- Pufnik A, K D. (2006) Short-term forecasting of inflation in croatia with seasonal arima processes. Croatia National Bank Working Paper, W-16
- Roache S (2013) Inflation persisttence in brazil-a cross country comparison. IMF Working Paper, Western Hemisphere Department, WP/14/55
- Roger M. Extended Poisson and games and the codorcet jury theorem. Games Econ Behav. 1998;25(1):111–131. doi: 10.1006/game.1997.0610. [DOI] [Google Scholar]
- Segal MR (2004) Machine learning benchmarks and random forest regression. Center for Bioinformatics and Molecular Biostatistics, UCSF
- Shaibu I, Osamwoni I. A comparative analysis of inflation dynamics models in Nigeria. Int J Acad Res Bus Soc Sci. 2020;10(2):557–558. [Google Scholar]
- Stock J, Watson M. Forecasting inflation. J Monetary Econ. 1999;44:293–335. doi: 10.1016/S0304-3932(99)00027-6. [DOI] [Google Scholar]
- Stock J, Watson M (2008) Phillips curve inflation forecast. National Bureau of Economic Research (NBER) Working Paper, p 14322
- Stock JH, Watson MW. Has inflation become harder to forecast? J Money Credit Banking. 2007;39:3–34. doi: 10.1111/j.1538-4616.2007.00014.x. [DOI] [Google Scholar]
- Stock JH, Watson MW. Dynamic Factor Models. In: Clements MP, Hendry DF, editors. The Oxford Handbook of Economic Forecasting. Oxford University Press; 2011. [Google Scholar]
- Tekatli N. A new core inflation indicator for Turkey. Central Bank Rev. 2010;10:9–21. [Google Scholar]
- Tule M, Salisu A, Ebuh G. A test for inflation persistence in Nigeria using fractional intergration and fractional cointegration techniques. Econ Model. 2020;87:225–237. doi: 10.1016/j.econmod.2019.07.024. [DOI] [Google Scholar]
- Tumala M, Olubusoye O, Yaaba B, Yaya O, AKanbi O (2017) Forecasting nigerian inflation using model averaging methods: Modelling frameworks to central banks. MPRA
- Yemitan R, Shittu O. Forecasting inflation in Nigeria by state space modeling. Int J Sci Eng Res. 2015;6(8):778–786. [Google Scholar]
- Younus S, Roy A (2016) Forecasting inflation and output in Bangladesh: evidence from a var model. Research department and Monetary Policy Department of Bangladesh Bank Working Paper series, 1610:778–786
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Supplementary Materials
Data Availability Statement
The data that support the findings of this study are available from the corresponding author upon reasonable request.
The views expressed in this paper are those of the authors, and do not necessarily reflect the views of anyone else affiliated with the Central Bank of Nigeria and CAPE Economic Research and Consulting. Any correspondence should therefore, be shared through the emails provided.









