Skip to main content
Springer Nature - PMC COVID-19 Collection logoLink to Springer Nature - PMC COVID-19 Collection
. 2023 Jun 5;3(7):110. doi: 10.1007/s43546-023-00490-9

South African inflation modelling using bootstrapped long short-term memory methods

Sihle Kubheka 1,✉
PMCID: PMC10240137  PMID: 37304375

Abstract

Inflation is a critical economic series, and proper targeting is required for a stable economy. With the current economic conditions that the world has faced as a result of COVID-19, understanding the effects of this on economies is critical because it will guide policies. Recent research on South African inflation has focused on statistical modelling, specifically the ARFIMA, GARCH, and GJR–GARCH models. In this study, we extend this into deep learning and use the MSE, RMSE, RSMPE, MAE, and MAPE to assess performance. To test which model has better forecasts, we use the Diebold–Mariano test. According to the findings of this study, clustered bootstrap LSTM models outperform the previously used ARFIMA–GARCH and ARFIMA–GJR–GARCH models.

Keywords: Inflation, ARFIMA, GARCH, GJR–GARCH, LSTM

Introduction

Inflation is an important macroeconomic factor in a country because it directly affects the economy and its participants. Every month, inflation is adjusted based on changes in the prices of a specific basket of goods. This adjustment then informs the economy about the current change in consumer prices. Misunderstandings about inflation are likely to have economic, political, and social consequences (Kołodko 1989; Harmse 2006; Aucoin 2016). Falling real incomes, which are part of the economic consequences, may be experienced when inflation rises faster than income rises or when savings interest rates fall faster than inflation rises. Thus, understanding inflation, as well as careful monitoring and targeting, is required for a stable economy. In South Africa, the inflation rate must be between 3 and 6to remain stable. This targeting is part of monetary policy and is implemented by the South African Reserve Bank (SARB) (Smal and De Jager 2001; Woglom 2003; Van der Merwe 2004; Fedderke and Schaling 2005; Hodge 2005).

The non-linear nature of inflation has been extensively discussed in the literature. It is now known that inflation data contain structural changes, which are primarily attributed to policy changes and economic growth (Nell 2018) and can currently be accounted for in a non-linear model. A number of studies have been conducted in South Africa to investigate the non-linearity of the inflation rate. Balcilar et al. (2016) used an autoregressive fractionally integrated moving average (ARFIMA) model with a Markov-switching fractional differencing parameter to analyze South African inflation rate. Boateng et al. (2017) investigated Ghana and South African inflation rates using an ARFIMA model with innovations explained by GARCH and Glosten, Jogannathan, and Runkle–GARCH (GJR–GARCH) models. Non-linearity, structural breaks, and fractional integration were investigated in the analysis of Ghana and South African inflation rates by Boateng et al. (2018).

Regarding inflation modelling in machine learning, Medeiros et al. (2019) used the random forest model which was compared to other machine learning methods. The random forest model was selected because of its ability of variable selection and non-linearities between covariates and inflation. Almosova and Andresen (2019) used LSTMs to forecast inflation because of its ability to capture non-linearities and compared the model to econometric methods. Botha et al. (2022) studied the South African inflation by using big data and a number of goods and services as predictors. They combined the use of big data and statistical methods which provided a combination of models that could compete with most benchmark models. However, they noted that many of the traditional benchmark models are superior over short-term horizons and sparse models are superior to those of dense models when they used disaggregated data.

In this study we will use univariate statistical methods as benchmark models. We try a machine learning approach to address both the mean and volatility dynamics of inflation in this study by:

  1. Investigating if bootstrapping can improve inflation forecasting by using a clustered bootstrap algorithm.

  2. Examining if the South African inflation rate can be explained by an LSTM technique as compared to previously used ARFIMA–GARCH methods.

  3. Employing different forecasting evaluation measures to compare different models.

To investigate the mean model of the inflation rate data, we use the clustered bootstrap method to select blocks for modelling and then apply LSTM to the sample data, which will be compared to the ARFIMA–GARCH and ARFIMA–GJR–GARCH models used by Boateng et al. (2017). Volatility will be modelled using the GARCH and GJR–GARCH models for comparison. We will use various forecasting diagnostics to examine and compare forecasts from both the mean and volatility models.

This study has potential limitations. The forecasts of inflation are based on univariate models so that we examine the use of clustering in bootstrapping. In further studies, we will use multivariate techniques as an extension of this study. This paper is organized as follows: the following section discusses the bootstrap methods used for time series data, and "Long short-term memory (LSTM) models" discusses LSTM models which are used in the paper. Mean and volatility models are discussed in the next section and data are described in Section 5. In Section 6 we discusses empirical results from the models and we conclude in the final section.

Bootstrap methods

Bootstrapping has been one of the succesful techniques in data analysis and forecasting. Reasons for the wide use of this technique, especially recently, is the large amount of data that are produced as well as the inability of computing power to calculate all the data in a timely manner. Bootstrapping then becomes the method of choice in this regard. There are a number of bootstrapping techniques that have been introduced, but for independent data block bootstrapping methods are used.

To understand bootstrapping for independent data, let X1,X2,... be a sequence of iid random variables with a common distribution F. Suppose χn={X1,...,Xn} generate the data at hand and let Tn=tn(χn;F),n≥1 be a random variable of interest. Let Gn denote the sampling distribution of Tn.

To get blocks from the data, suppose χn={X1,..,Xn} denotes the total observations. Let Bi=(Xi,...,Xi+l-1) denote the block of length l starting with Xi,1≤i≤N, where N=n-l+1. To get the bootstrap samples, we randomly select from the collection {B1,..,BN}. Accordingly, let B1∗,..,Bk∗ denote a simple random sample of k blocks drawn with replacement from {B1,..,BN} and each of the selected blocks contain l elements. Denote the elements of Bi∗ by (X(i-1)l+1∗,...,Xil∗),i=1,...,k. Then, X1∗,..,Xm∗ constitute the MBB sample of size m=kl.

Note that selecting the blocks Bi∗s randomly from {B1,..,BN} is equivalent to selecting k indices at random from the set {1,...,N}. Let I1,..,Ik be iid random variables with the discrete uniform distribution on {1,..,N}. If we set Bi∗=BIi, for i=1,...,k then B1∗,...,Bk∗ represent a simple random sample drawn with replacement from {B1,...,BN}.

Long short-term memory (LSTM) models

In deep learning literature, neural network models are mostly used to model any phenomenon. However, when it comes to sequential data with temporal dynamics, these models fail. RNNs on the other hand have been used to model these dynamics. However, because of their inability to model long-range dependencies, LSTMs were introduced.

A feature of the RNN architecture is that of a cyclic connection which enables the RNN to update the current state based on previous states as well as the current input data. A shortcoming of the RNN architecture is the inability to discriminate between relevant and irrelevant data when the data is large. To enable the modelling of long data or long-range dependencies, LSTM models are used. Because of the powerful capabilities that LSTM models possess, they have been applied in a number of applications and this includes speech recognition and temporal dynamics models amongst others.

LSTM cells are designed to have improved memory and this was done by introducing a gate into the cell. Because of this, LSTMs have been extended where some have a forget gate and some have not, and others have a peep hole connection.

The mathematical expression of an LSTM cell with a forget gate is defined as

ft=σ(Wfhht-1+Wfxxt+bf),it=σ(Wihht-1+Wixxt+bi),ct~=tahn(Wc~hht-1+Wc~xxt+bc~),ct=ct-1+it.c~t,ot=σ(Wohht-1+Woxxt+bo),ht=ot.tanh(ct), 1

where ft is the forget gate, ct is the cell state, W are weights, b is the bias, ht is the recurrent information and ot is the output cell. The forget gate, ft, decides what information to forget or be thrown away from the cell state. The forget gate does this by using a binary decision such that if its value is 1, then the piece of information is kept and if it is a 0 then that information would be discarded.

Mean and volatility models

To investigate long memory mean and volatility models of the South African inflation rate, we used an ARFIMA model to model the mean dynamics. To compare against literature, we use the GARCH and GJR–GARCH and discuss these models below.

The ARFIMA (p,d,q) model is defined as

ϕ(L)(1-L)dXj=θ(L)aj,aj=σjϵj,ϵj∼N(0,1), 2

where ϕ(L)=1-ϕ1L-ϕ2L2-...-ϕpLp and θ(L)=1+θL+θ2L2+...+θqLq are lag polynomials, d is the long-range dependence parameter and L is the lag operator. The ARFIMA model is stationary if the long-range dependence parameter is between - 0.5 and 0.5. To cater to non-constant variance, we use heteroskedastic models. The GARCH model is a short memory model, which can be used to explain volatility clustering and heteroskedasticity. The GARCH(m,s) model is defined as

σt2=α0+∑i=1mαiat-i2+∑j=1sβjσt-j2, 3

where {ϵt} is a sequence of i.i.d random variables, which means E(ϵt)=0 and Var(ϵt) = 1, with α0>0, αi≥0, βj≥0 and ∑i=1(m,s)(αi+βi)<1. The GJR–GARCH model is defined by

σt2=ω+∑i=1qαiat-i2+∑i=1qδSt-i-at-i2+∑j=1pβjσt-j2, 4

where St-i- is a variable which takes 1 if at-i is negative and 0 otherwise.

Data

Data used in this paper are the monthly inflation figures as provided by Statistics South Africa (Stats SA) from January 1978 to November 2022. The inflation rate was calculated from the consumer price index (CPI) figures by using December 2012 as the base date. We have seasonally adjusted the data to cater to the seasonalities in the inflation data series and the analysis and forecasting are done on a month to month data basis.

Figure 1 shows the monthly inflation series from January 1978 to November 2022. Table 1 shows the descriptive statistics. Tests for normality in Table 2 that were used are the Shapiro–Wilk, Kolmogorov–Smirnov, and Anderson–Darling test. The tests illustrate that the series are not normally distributed.

Fig. 1.

Fig. 1

Inflation rate from January 1978 to November 2022

Table 1.

Descriptive statistics

Statistic Value
Quartile 1 0.0530
Median 0.0840
Quartile 3 0.1285
Mean 0.0903

Table 2.

Normality tests

Test Test statistic P value
Shapiro–Wilk 0.9579 0.0001
Kolmogorov–Smirnov 0.5193 0.0001
Anderson–Darling 9.6490 0.001

Figure 2 shows the normal quartile–quartile (QQ) plot which further shows that the quantiles do not align.

Fig. 2.

Fig. 2

Normal QQ plot of inflation rate

Normality tests of inflation

Table 3 shows unit root tests. The Philip–Perron test shows that the inflation series are stationary in mean at 5 % level of significance. The Philips–Perron test in used in this paper since it is robust to the presence of serial correlation and heteroskedasticity. The Dickey–Fuller generalized least squares (DF-GLS), augumented Dickey–Fuller (ADF) and Kwiatkowski–Phillips–Schmidt–Shin (KPSS) statistics show that the inflation series are stationary in mean at 1 % level of significance. Figure 3 shows the ACF plot and it illustrates that the inflation series exhibit long memory, which is shown by the structure of the ACF plot.

Table 3.

Unit root tests of inflation

Test Test statistic P value
Phillips–Perron - 24.4000 0.0274
DF-GLS - 3.2667 0.0001
ADF - 4.2099 0.0001
KPSS 4.9941 0.001

Fig. 3.

Fig. 3

The ACF Plot

Empirical results

We fitted two statistical models, the ARFIMA–sGARCH and the ARFIMA–GJR–GARCH to better understand the dynamics of South African inflation.

The long memory ARFIMA model was used to explain the mean, and the standard GARCH and GJR–GARCH models were used to explain the innovations. The LSTM model, which used clustered bootstrap data to model the inflation time series, was the second model we used. In this section, we discuss and compare the results of these models using the mean square error (MSE), mean absolute error (MAE), mean absolute percentage error (MAPE), root mean square error (RMSE) and root mean square percentage error (RMSPE).

Forecast evaluation methods

Forecasting model evaluation is important because it helps us understand the forecasting accuracy of the models estimated. The literature contains a number of forecast evaluation measures. We used five commonly used measures in the literature for our analysis: MSE, MAE, MAPE, RMSE and RMSPE. These measures are defined as follows:

MSE=1n∑t=1nyt-y~t2, 5
RMSE=1n∑t=1nyt-y~t2, 6
RMSPE=1n∑t=1nyt-y~tyt2, 7
MAE=1n∑t=1n∣yt-y~t∣2, 8

and

MAPE=1n∑t=1nyt-y~tyt, 9

where n is the number of forecasts, yt is the observed inflation and y~t is the predicted inflation at time t. The best model must exhibit least prediction error as given by these measures.

To further compare the forecast accuracy of the different models, we use the modified Diebold–Mariono (DM) in Harvey et al. (1997) test. This is an asymptotic test of the hypothesis that the mean of the loss differential series is zero. The the test statistic is

DM=d¯σ^d, 10

where d¯ is the sample mean of the loss differential and σ^d is a consistent estimate of the standard deviation. In this study, we use R statistical software to conduct this test.

Model results

The data used is the inflation data from January 1978 to November 2022. To fit the models, we split the data into training and testing datasets. The training dataset is from January 1978 to December 2021 and for testing of the models we used data from January 2022 to November 2022.

For the LSTM model, we used a simple architecture with an input layer, four hidden layers and an output layer. The input data was reshaped into 50 lagged variables, which resulted in 50 nodes for the input layer and the hidden layers, the output layer had only 1 node.

To fit the benchmark models, we used the inflation time series data and to fit the LSTM model we used the clustered bootstrapped data. To create the clustered bootstrap samples, we split the data into blocks with a block length of 20. Data time warping is then used to calculate distances between blocks, which measures similarity between the blocks and a distance matrix is produced. K-means algorithm is then used to cluster the data and the number of clusters is found by using the knee locator algorithm. When sampling the input data into the LSTM model, we equally sample from each cluster and sort the data to keep temporal information.

We fitted three models to understand the inflation dynamics: the standard GARCH model, the GJR–GARCH model, and the clustered bootstrap LSTM model.

In this study, the GARCH models were used for comparison purposes because they had previously been used to model inflation dynamics in South Africa. The long memory ARFIMA models with GARCH models to model the inflation process are the mean models for both of these models. The results of ARFIMA–GARCH models are shown in Tables 4 and 5, with Table 4 using the standard GARCH model and Table 4 using the GJR–GARCH model for innovation.

Table 4.

ARFIMA–sGARCH model output

Parameter Estimate Standard error t value P value
mu 0.1538 0.0063 24.3191 0.0001
ar1 0.4726 0.1793 2.6357 0.0008
ma1 - 0.2488 0.2018 - 1.2332 0.2175
arfima 1.0000 NA NA NA
omega 0.0001 0.0001 2.1695 0.0304
alpha1 0.1895 0.0592 3.2013 0.0014
beta1 0.3002 0.2628 0.1424 0.2532

Table 5.

ARFIMA–GJR–GARCH model output

Parameter Estimate Standard error t value P value
mu 0.1531 0.0049 0.3081 0.0001
ar1 0.1585 0.0548 2.8949 0.0037
ma1 - 0.1358 0.0403 3.3687 0.0008
arfima 1.0000 NA NA NA
omega 0.0001 0.0001 0.0793 0.9368
alpha1 0.0312 0.0001 0.0001 0.0001
beta1 0.9963 0.0001 0.0001 0.0001
gamma1 - 0.0569 0.0001 - 0.0033 0.0001

The forecasting error measurements are shown in table 6. We used the MSE, RMSE, MAPE, RMSPE, and MAE to compare to previous studies. According to the results, the clustered bootstrap LSTM outperforms both the standard GARCH and the GJR–GARCH models.

Table 6.

Forecasting error measurements

Model MSE RMSE MAPE RMSPE MAE
sGARCH 0.000062 007878 11.469400 0.120130 0.007644
gjrGARCH 0.000079 0.008894 11.796020 0.125235 0.008204
CB-LSTM 0.000034 0.005829 7.998317 0.088936 0.005312

When comparing the forecasts from the three models, we used the Diebold–Mariano test with a null hypothesis that the clustered bootstrap LSTM model has better forecasts than the ARFIMA–sGARCH and ARFIMA–GJR–GARCH model. For the comparison between LSTM and the ARFIMA–GJR–GARCH, the test statistic was DM = 0.3377 with a P value = 0.3707, and for the ARFIMA–sGARCH model the test statistic was DM = 0.3879 with a P value = 0.3524. This suggests that we cannot reject the null hypothesis at 5% level of significance and hence we cannot conclude that the clustered bootstrap LSTM model does not have better forecasts.

Conclusion

With the current economic conditions that the world has been subjected to as a result of COVID-19, understanding the effects of this on economies is a critical exercise that will guide policies.

As a result of multiple recessions, a high unemployment rate, and a slow economy, South Africa is currently experiencing multiple recessions. Understanding and forecasting key economic performance indicators are critical. In this study, we looked at inflation, which should always be between 3% and 6% in South Africa.

Recent research on South African inflation has focused on statistical modelling, specifically the ARFIMA, GARCH, and GJR–GARCH models. In this study, we extend this into deep learning and use the MSE, RMSE, MAPE, RMSPE, and MAE to assess performance.

According to the findings of this study, clustered bootstrap LSTM models outperform the previously used ARFIMA–GARCH and ARFIMA–GJR–GARCH models. Further, we used the Diebold–Mariano test to confirm that clustered bootstrap LSTM models have better forecasts.

This study has some limitations. The models used in this study are univariate models and benchmark models are statistical models. In future research, we will utilize multivariate models and also compare different bootstrapping methods with both statistical and deep learning methods.

Author Contributions

Not applicable.

Funding

Not applicable.

Data Availability

Data is available online freely from the South Africa Statistical Association

Declarations

Conflict of interest

Not applicable.

Ethical approval

Not applicable.

Consent to participate

Not applicable.

Consent for publication

Not applicable.

Code availability

Available on request.

References

  1. Almosova A, Andresen N (2019) Nonlinear inflation forecasting with recurrent neural networks
  2. Aucoin C, Cilliers J. Economics, governance and instability in South Africa. Inst Secur Stud Pap. 2016;293:1–24. [Google Scholar]
  3. Balcilar M, Gupta R, Jooste C. Analyzing South Africa’s inflation persistence using an Arfima model with Markov-switching fractional differencing parameter. J Dev Areas. 2016;50(1):47–57. doi: 10.1353/jda.2016.0004. [DOI] [Google Scholar]
  4. Boateng A, Lesaoana M, Siweya H, et al. Modelling persistence in the conditional mean of inflation using the Arfima process with Garch and Gjrgarch innovations: the case of Ghana and South Africa. Afr Rev Econ Finance. 2017;9(2):96–130. [Google Scholar]
  5. Boateng A, Lesaoana M, Siweya H, et al. Non-linearities, structural breaks and fractional integration in the analysis of the Ghanaian and the South African cpi inflation rates. J Dev Areas. 2018;52(1):157–168. doi: 10.1353/jda.2018.0010. [DOI] [Google Scholar]
  6. Botha B, Burger R, Kotzé K et al (2022) Big data forecasting of South African inflation. Empir Econ 1–40 [DOI] [PMC free article] [PubMed]
  7. Fedderke J, Schaling E. Modelling inflation in South Africa: a multivariate cointegration analysis. S Afr J Econ. 2005;73(1):79–92. doi: 10.1111/j.1813-6982.2005.00006.x. [DOI] [Google Scholar]
  8. Harmse C (2006) The relationship between South Africa’s macroeconomic policies and the performance of various asset classes. In: Macroeconomic policy challenges for South Africa conference, Pretoria, pp 22–24
  9. Harvey D, Leybourne S, Newbold P. Testing the equality of prediction mean squared errors. Int J Forecast. 1997;13(2):281–291. doi: 10.1016/S0169-2070(96)00719-4. [DOI] [Google Scholar]
  10. Hodge D. Inflation and growth in South Africa. Camb J Econ. 2005;30(2):163–180. doi: 10.1093/cje/bei051. [DOI] [Google Scholar]
  11. Kołodko GW. Social and political aspects of inflation. East Eur Econ. 1989;27(3):50–60. doi: 10.1080/00128775.1989.11648411. [DOI] [Google Scholar]
  12. Medeiros MC, Vasconcelos GF, Veiga A et al (2019) Forecasting inflation in a data-rich environment: the benefits of machine learning methods. J Bus Econ Stat 1–22
  13. Van der Merwe E. Inflation targeting in South Africa. South Africa: South African Reserve Bank Pretoria; 2004. [Google Scholar]
  14. Nell KS. Re-examining the role of structural change and nonlinearities in a Phillips curve model for South Africa. S Afr J Econ. 2018;86(2):173–196. doi: 10.1111/saje.12187. [DOI] [Google Scholar]
  15. Smal M, De Jager S (2001) The monetary transmission mechanism in South Africa. South African Reserve Bank Pretoria
  16. Woglom G. How has inflation targeting affected monetary policy in South Africa? S Afr J Econ. 2003;71(2):380–406. doi: 10.1111/j.1813-6982.2003.tb01314.x. [DOI] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

Data is available online freely from the South Africa Statistical Association


Articles from Sn Business & Economics are provided here courtesy of Nature Publishing Group

RESOURCES