# Electricity Consumption Forecasting in Algeria using ARIMA and Long Short-Term Memory Neural Network

Sahed Abdelkader, Kahoui Hacene

► To cite this version:

Sahed Abdelkader, Kahoui Hacene. Electricity Consumption Forecasting in Algeria using ARIMA and Long Short-Term Memory Neural Network. International Journal of Economic Performance -, 2023 06 (01). hal-04183403

HAL Id: hal-04183403

https://cnrs.hal.science/hal-04183403v1

Submitted on 19 Aug 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
# Electricity Consumption Forecasting in Algeria using ARIMA and Long Short-Term Memory Neural Network

Sahed Abdelkader *

sahed14@yahoo.fr

University Centre of Maghnia (Algeria)

Kahoui Hacene

hacenkahwi@gmail.com

University Centre of Maghnia (Algeria)

Submitted:20/11/2022

Accepted:13/03/2023

Published:04/06/2023

## Abstract:

Forecasting electricity consumption is necessary for electric grid operation and utility resource planning, as well as to improve energy security and grid resilience. Thus, this research aims to investigate the prediction performance of the ARIMA and LSTM neural network model using electricity consumption data during the period 1990 to 2020. The time series for electricity consumption is divided into 70% for training data and 30% for test data. The results showed that the LSTM model provided improved forecasting accuracy than the ARIMA model.

**Key words:** Electricity Consumption; ARIMA; LSTM; Algeria.

**JEL Classification Codes:** Q47, C53, C45.

<footnote>* Corresponding author</footnote>
**Introduction :**

Energy is one of the most vital factors of every country's economic and social
growth. The use and provision of energy are the most crucial modern challenges for the
progress of any economic sector. According to classical economists the labor and capital
are the main factor in the process of production while ignored the role of energy in
economic growth. However, neoclassical economists strained on increase in
productions due to increase in labor, capital, and technology, and modern studies
recommends that energy plays key role in the economic growth of developing nations.
Nevertheless, energy uses increase the employment opportunity to expand the
economic activities and to fulfill the necessities of agricultural, industrial, transportation
and commercial sectors. Thus, energy sector has a significant contribution to the
economic growth of a country (Wahid, F., et al, 2021, p241).

Global energy consumption is increasing rapidly due to population growth,
continued pressure to improve living standards, a focus on large-scale production in
developing countries, and the need to maintain positive rates of economic
development. With this in the fact, a robust forecasting approach is essential to
accurately plan investments in energy production, consumption, and distribution
(Bianco, V., et al, 2009, p1413).

Electricity consumption in the industry is increasing, requiring the use of
advanced deep learning tools such as LSTM. Furthermore, the consumption of
electricity in the building projects is expanding due to the cooling, heating, and lighting
processes, which vary depending on the building area and the operational process of
electronic processing. Moreover, electricity consumption is not dominated by the
industrial sector, but also includes agriculture, mining and construction (Azadeh, A. G.
H. A. D. E. R. I., et al, 2008, p2272).

Algeria has known a significant increase in the demand for the needs of the
various sectors of energy, especially electric energy, which it cannot provided to it from
gas sources and petroleum products, which are not sufficient to meet the needs of
citizens and other industrial sectors, and that any increase in the price of electricity will
be borne by the citizen by increasing the prices of foodstuffs in the local market. According to the latest statistics, the construction sector in Algeria consumes the most electricity (43%), followed by the transport sector (36%) and the industrial sector (21%). Among the most important reasons for the increase in electricity consumption are population growth, the decrease in electricity prices, the use of cheap electrical equipment and the absence of rationality in electricity consumption (Ghedamsi, R., et al, 2016, p309).

Many papers have been published in the last ten years on electricity consumption using various forecast methods, due to the continuous increase in electricity consumption, which necessitates accurate planning in order to avoid electricity shortages and ensure adequate infrastructures. We mention the most important ones.

Fan, G. F., et al (2020) In this study has developed a novel hybrid forecasting model, that is EMD-SVR-PSO-AR-GARCH model. It takes a fresh look at electricity use and consumer economic behavior. The Nash equilibrium and Porter's five-force model are used to analyze the complex electricity usage and consuming behaviors. To determine the electricity regulation and economic development, support the sustainable development of electricity.

Gellert, A., et al (2022) This study aims to find an accurate method to predict electrical energy consumption and production. Being able to anticipate how consumers will use energy in the near future may help optimize their behavior. Results show a mean absolute error of 73.62 Watts for the TBATS model, which is far better than the one obtained with neural forecasting methods.

Hao, J., et al (2019) In this study, to forecast electricity demand, a new ensemble forecasting model with nonlinear optimization is proposed. The basic forecasting models, such as exponential smoothing, ARIMA, SVR and extreme learning machine, the results of which have been combined. The results show that the ensemble technique outperforms the single and average integrated models in terms of accuracy when the clean electricity demand of major areas of the world is used as a sample.

Through the above, we suggest the following research question:
What is the effectiveness of the Long Short-Term Memory (LSTM) Neural Network in electricity consumption forecasting in Algeria
during the period 1990-2020?

**Study hypothesis:** To answer the research problem, the following hypothesis was formulated:

The using of deep learning models represented in STLM gives better and more accurate results in forecasting electricity consumption in Algeria during the period 1990-2020.

The remainders of the paper are organized as follows. Section II provides methods and materials. Then Section III presents the results and discussions. Finally, section IV gives the conclusions.

# 1. Methods and Materials

## 1.1 ARIMA

In the statistical literature, the autoregressive integrated moving average (ARIMA) approach is well-established in time series analysis of Short-Term Forecasting. To implement the ARIMA models, it consisted of three steps, identification based on AIC criterion, parameter estimate using maximum likelihood method, and diagnostic check based on statistical tests. It may be denoted as ARIMA (p, q), which is a linear combination of past values of $X_t$ and errors $\epsilon_t$ (Ho, S. L., & Xie, M, 1998, p214).

$$X_t = \Psi_0 + \phi_1 X_{t-l} + \phi_2 X_{t-2} + \dots + \phi_p X_{t-p} - \theta_l \epsilon_{t-l} - \theta_2 \epsilon_{t-2} - \dots - \theta_q \epsilon_{t-q} + \epsilon_t \quad (1)$$

where $p$ and $q$ are the order of the autoregressive model and moving average model respectively, $\{\phi_l, \phi_2, \dots, \phi_p, \theta_l, \theta_2, \dots, \theta_q\}$ are the regression weights to be estimated, $\Psi_0$ represents the constant, and $\{\epsilon_t, \epsilon_{t-1}, \epsilon_{t-2}, \dots, \epsilon_{t-q}\}$ are the random errors.

## 1.2 Long Short-Term Memory Method (LSTM)

The Long short-term memory (LSTM) proposed by Hochreiter and Schmidhuber. It is a type of time-cyclic neural network and that used to solve the long-term correlation problem of generic RNNs. LSTM was first used in deep learning and was adopted by researchers in thereafter works. (Wu, X., et al, 2021, p6).

<figure><img src="image_2.png" /></figure>
Therefore, each LSTM is a collection of cells that capture and store data streams. LSTM networks construct a transmission line that joins one module to another, transporting data from the past and storing it for the present. Data can be disposed of, filtered, or added for the following cells using gates in each cell. Its gates are founded on a sigmoidal neural network layer, which allows the cells to choose whether to let input flow through or discard it (Dissanayake, B., et al, 2021, p566).

The LSTM module's hidden layer is also known as a memory module. Figure 1 represents the specific pattern. Memory modules are sometimes compared to computer memory to aid comprehension. A storage unit and three processing units make up the memory module. Input gates, output gates, and forget gates are three computer components that regulate the reading, writing, and resetting of memory cell data, successively (Xu, D., et al, 2022, p12).

<figure><img src="image_3.png" /><figcaption>Fig.1. LSTM Architecture</figcaption></figure>

Source: Yadav, A., et al, 2020, p2093
The LSTM unit algorithm is represented by calculating the following equations:

The second equation ($i_t^j$) is the input gate.

$$i_t^j = \sigma(W_{xi}x_t + W_{hi}h_{t-1} + b_i)^j \quad (2)$$

The third equation ($f_t^j$) is the forget gate.

$$f_t^j = \sigma(W_{xf}x_t + W_{hf}h_{t-1} + b_f)^j \quad (3)$$

The fourth equation ($\sigma_t^j$) is the output gate.

$$\sigma_t^j = \sigma(W_{x\sigma}x_t + W_{h\sigma}h_{t-1} + b_\sigma)^j \quad (4)$$

Where:

$\sigma$ is sigmoid function.

W terms are weight matrices and b terms are voltage vectors.

With ($c_t^j$), the LSTM unit saves its memory at t time. Equation is used to update the equation whose memory cell is supplied (5).

$$c_t^j = f_t^j c_{t-1}^j + i_t^j \sigma_t^j \quad (5)$$

Equation (6) is used to update the new memory content, and equation (7) is used to generate the output for the LSTM unit (7) (Soy Temur, A., et al, 2019, 927).

$$f_t^j = \tanh(W_{xc}x_t + W_{hc}h_{t-1} + b_c)^j \quad (6)$$

$$h_t^j = \sigma_t^j \tanh(c_t^j) \quad (7)$$

## 1.3 Performance Criteria

The measure of performance is the root mean squared error (RMSE) and mean percentage absolute error (MAPE) used to evaluate the forecast accuracy of the proposed model. The formulas for calculating these criteria are as follows (Shabri, A., Samsudin, R. 2015 p. 3):

$$\text{RMSE} = \sqrt{\frac{1}{n} \sum_{t=1}^{n} (y_t - \hat{y}_t)^2} \quad (8)$$

$$\text{MAPE} = \frac{1}{n} \sum_{t=1}^{n} \left| \frac{y_t - \hat{y}_t}{y_t} \times 100 \right| \quad (9)$$

where $y_t$ denotes the actual data, $\hat{y}_t$ is the predicted value for period t, and n denotes the number of observations. Therefore, the lower the RMSE and MAPE values,

<figure><img src="image_4.png" /></figure>
the more efficient the model.

**2. Results and Discussion**

The ARIMA, a linear methodology commonly used in time series forecasting, and
the LSTM network, a nonlinear method utilized in deep learning algorithms, were
applied to the electricity consumption data in Algeria. Each method was written in
MATLAB program.

**2.1 Data**

In order to compare the two models, we used Algeria's electricity consumption data. The study period extended the time period from 1990 through the end of 2020. This is for forecasting the Electricity Consumption in Algeria (ELC). For the evaluation of the quality of the proposed models, we divided the time series into a train and test time series, where the training series consists of the data for 1990 until the end of 2011, and the test series consisting of data for 2012 until 2020 (see Figure 2).

<figure><img src="image_5.png" /><figcaption>Fig.2. Electricity Consumption in Algeria from 1990 to 2020</figcaption></figure>

Source: prepared by the authors based on information from the website
https://www.iea.org/countries/algeria.

**2.2 ARIMA Models Results**

In first, the ADF test was used to study the Stationarity of the training time series
of electricity consumption in Algeria. Where the null hypothesis was accepted with a
probability (p=0.999), that meaning the series is non-stationary differences at level,

<figure><img src="image_6.png" /></figure>
therefore the first of the series were taken and tested again, where the alternative
hypothesis was accepted with a probability (p=0.0095), so the time series of electricity
consumption is stationary at first difference I(1).

In order to identify the model, the sample and partial autocorrelation function was
used, taking into the lowest value for (AIC= 65.158) and BIC=67.34) criterions. Where
the ARIMA (9.1.0) model was selected and using the maximum likelihood method was
estimated. Furthermore, the training time series of electricity consumption was
compared with the fit model of ARIMA (9.1.0), and we note that there is a significant
closeness between them (see Figure 3).

<figure><img src="image_7.png" /><figcaption>Fig.3. Comparison between the ARIMA model and the original data</figcaption></figure>

Source: prepared by the authors

2.3 LSTM Models Results

The data for the LSTM network method must be in supervised learning mode. As a result, we have a target variable Y and a predictor X. To do this, we transform the series of electricity consumption by lagging the series and having the value at time (t-1) as the input and the value at time (t) as the output, for a 1-step delayed dataset.

Then samples are randomly selected from the training and test data sets, so the

<figure><img src="image_8.png" /></figure>
order of the observations should be important, the first 70% of the series as training set and the remaining 30% as test set.

The input data is rescaled to fit the range of the activation function. The sigmoid function with the range [-1, 1] is the default activation function for LSTM. It is worth noting that the scaling factors used to scale both the training and testing data sets are the min and max values from the training data set. This assures that the test data's minimum and maximum values have no impact on the model.

After many parameter adjustments, the Adam optimization approach to boost convergence speed and Root Mean Squared Error as the loss function was used for training the LSTM neural network. The hyperparameter to 50 hidden layer cells with a learning rate of 0.001 based on repeated trials. The best results were obtained when the model was trained across 1000 epochs.

As seen in Figure 4, the LSTM model performed well in fitting the test datasets. Then, to show the efficacy of the proposed model, we evaluate its performance and compare it to the ARIMA model.

<figure><img src="image_9.png" /><figcaption>Fig.3. Comparison between the LSTM model and the test data</figcaption></figure>

Source: prepared by the authors
As a result, the root mean square error (RMSE) and mean absolute percentage error (MAPE) were used to evaluate the models' performance on the test set. Table 1 displays the results of the comparison between the ARIMA and the LSTM model. We can see that LSTM has the best performance, with the lowest root mean square error and mean absolute percentage error. As a result, the ARIMA model is less accurate than the LSTM model. We indicate that the LSTM model beats the ARIMA model significantly in forecasting electricity consumption in Algeria.

<table><caption>**Table 1.** Prediction evaluation</caption><thead><tr><td>Model</td><td>RMSE</td><td>MAPE</td></tr></thead><tbody><tr><td>ARIMA</td><td>13.07188187</td><td>0.1557</td></tr><tr><td>LSTM</td><td>6.5277</td><td>0.0981</td></tr></tbody></table>

Source: elaborated on by the authors

**Conclusion:**

An efficient process forecasting in the electricity sector minimizes uncertainty and allow for more logical decisions in electricity distribution management, making the electricity sector more resilient in the face of unpredictability and maintaining an uninterrupted supply of energy to consumers and businesses. In this article, we compared the ARIMA and LSTM models for predicting energy consumption in Algeria. The forecasting quality criteria demonstrate that the LSTM model had higher forecasting accurate than the ARIMA model in terms of both RMSE and MAPE criteria.

**Referrals and references:**

- Wahid, F., Ullah, H., Sher, A., Jan, S. A., Abid, A., Khan, A., ... & Bibi, M. (2021). *The Determinants and Forecasting of Electricity Consumption in Pakistan*. International Journal of Energy Economics and Policy, 11(1), 241-248.

- Bianco, V., Manca, O., & Nardini, S. (2009). *Electricity consumption forecasting in Italy using linear regression models*. Energy, 34(9), 1413-1421.

<figure><img src="image_10.png" /></figure>
- Azadeh, A. G. H. A. D. E. R. I., Ghaderi, S. F., & Sohrabkhani, S. (2008). *Annual electricity consumption forecasting by neural network in high energy consuming industrial sectors*. Energy Conversion and management, 49(8), 2272-2278.

- Ghedamsi, R., Settou, N., Gouareh, A., Khamouli, A., Saifi, N., Recioui, B., & Dokkar, B. (2016). *Modeling and forecasting energy consumption for residential buildings in Algeria using bottom-up approach*. Energy and Buildings, 121, 309-317.

- Fan, G. F., Wei, X., Li, Y. T., & Hong, W. C. (2020). *Forecasting electricity consumption using a novel hybrid model*. Sustainable Cities and Society, 61, 102320.

- Gellert, A., Fiore, U., Florea, A., Chis, R., & Palmieri, F. (2022). *Forecasting Electricity Consumption and Production in Smart Homes through Statistical Methods*. Sustainable Cities and Society, 76, 103426.

- Hao, J., Feng, Q., Suo, W., Gao, G., & Sun, X. (2019). *Ensemble forecasting for electricity consumption based on nonlinear optimization*. Procedia Computer Science, 162, 19-24.

- Ho, S. L., & Xie, M. (1998). *The use of ARIMA models for reliability forecasting and analysis*. Computers & industrial engineering, 35(1-2), 213-216.

- Wu, X., Zhou, J., Yu, H., Liu, D., Xie, K., Chen, Y., ... & Xing, F. (2021). *The Development of a Hybrid Wavelet-ARIMA-LSTM Model for Precipitation Amounts and Drought Analysis*. Atmosphere, 12(1), 74.

- Dissanayake, B., Hemachandra, O., Lakshitha, N., Haputhanthri, D., & Wijayasiri, A. (2021). *A Comparison of ARIMAX, VAR and LSTM on Multivariate Short-Term Traffic Volume Forecasting*. In Conference of Open Innovations Association, FRUCT (No. 28, pp. 564-570). FRUCT Oy.

- Soy Temur, A., Akgun, M., & Temur, G. (2019). *Predicting housing sales in turkey using arima, lstm and hybrid models*. Journal of Business Economics and Management, 20(5), 920-938.

- Shabri, A., & Samsudin, R. (2015). *Fishery landing forecasting using wavelet-based autoregressive integrated moving average models*. Mathematical Problems in Engineering, 2015.

- Yadav, A., Jha, C. K., & Sharan, A. (2020). *Optimizing LSTM for time series prediction in Indian stock market*. Procedia Computer Science, 167, 2091-2100.

- Xu, D., Zhang, Q., Ding, Y., & Zhang, D. (2022). *Application of a hybrid ARIMA-LSTM model based on the SPEI for drought forecasting*. Environmental Science and Pollution Research, 29(3), 4128-4144.

<figure><img src="image_11.png" /></figure>