The Forecasting of Electrical Energy Consumption in Morocco with an Autoregressive Integrated Moving Average Approach

The national demand for primary energy has experienced an average increase of almost 5% in recent years, driven by the growth in electricity consumption, which grew by an average of 6% per year between 2003 and 2017, by virtue of the almost generalization of rural electrification and the dynamism of our economy and especially the policy of major works in infrastructure, industry, agriculture, tourism, and social housing. In fact, forecasting the demand for electrical energy remains a controversial issue in the development of the electricity grid and energy management. The ARIMA (1, 1, 1) model is applied to model electrical energy consumption for the annual period from 1971 to 2020. The same data are also used to predicting for 2021–2030 in order to verify the adequacy of the model and to provide information on the state of energy demand in Morocco in the future. The main results indicate an upward trend in electrical energy consumption by the end of 2030, with electricity consumption expected to be in the range of 2039639.09–53589.00 GWh per year.


Introduction
Energy is vital to the sustainable development of any nation, be it social, economic, or environmental. During the last decade, energy use has grown exponentially worldwide. e energy management is crucial to the economic future prosperity and environmental safety [1]. Predicting energy consumption is essential for energy planning, strategy formulation, and recommendation of energy policies [2]. Since energy consumption has always increased because of rapid population growth, particularly in the third world and emerging countries, this expansion is expected to continue in the near future, the world population from 7.5 billion today to about 9.5 billion over the next 30 years [3]. Such increase in population would produce a dramatic impact on energy demand, making at least double by 2030. A common method of statistical forecasting based on a rigorous study of time series is the ARIMA model. It is used to provide different random processes such as energy consumption, resource consumption, and prices.
is study attempts to forecast the evolution of carbon dioxide emissions in Morocco over the next two decades 2021-2030. Using the Box-Jenkins ARIMA approach provided by the ARIMA function within the forecasting package of the python software, comparison was performed based on the lowest criteria in order to select the appropriate ARIMA. e study unfolds as follows. Section 2 provides a brief overview of the most recent techniques used to estimate and forecast energy demand behavior. Section 3 consists of two parts: the first part reviews the methodologies and the forecasting approaches in details and the second part presents the selected data and summarizes the results of the quantitative analysis. Finally, Section 4 concludes the findings of the study and suggests directions for future work.

Related Works
Over the last few years, energy load forecasts have received an increasing attention from researchers. A lot of studies have used forecasting models with the time series dataset such as electrical power consumption. In China, Nyoni [4] aimed to predict CO 2 emissions during the period 1960-2017, using ARIMA (Jenkins-Box) methodology, and the study led to the selection of the best model for predicting CO 2 emissions from ARIMA. Also, the ARIMA model (1,2,1) is not only stable but also is the most appropriate model to predict the total CO 2 emissions in China over the next ten years, as the proposed model expects the total annual CO 2 emissions in 2024 in China. In the same context, Aurna et al. [5] carried out the two differences forecasting method to predict the electricity consumption in University Tun Hussein Onn Malaysia (UTHM). Farajian et al. [6] found out that the ARIMA (4,1,2) model achieved best performance for forecasting the agricultural energy demand in Iran [6]. In ailand, Sutthichaimethee [7] analysed CO 2 emissions using the VARIMAX approach over the period 2000-2015 and established that the VARIMAX (2, 1, 2) and VARIMAX (2, 1, 3) models are optimal models for modeling CO 2 emissions in ailand. Employing a novel bioinspired framework, Sangeetha and Amudha [8] predicted CO 2 emissions in India, and their results showed that the PSO model could obtain a highly accurate estimation compared to the MLR model. Haiges et al. [9] aimed at deploying the autoregressive integrated moving average (ARIMA) approach to adapt to the 40 years planned until 2053 by evaluating 40 years of past data from 1973 to 2013. In this evaluation, ARIMA (0, 2, 1) demonstrated better prediction in terms of accuracy during the retention period. Camara et al. [10] examined forecast performance for residential energy consumption data from the United States between SARIMA and ANN methodologies. ey conclude that the neural network model has a slight superiority over the SARIMA model, and these models are not directional. Pakrooh and Alipour [11] forecasted the consumption of energy types (petroleum products and electricity) in the Iranian agricultural sector using the ARIMA and ARFIMA models. e results showed that petroleum products do not have long-term memory, but electricity has long-term memory. According to the results of the models selected for each energy, the trend of the consumption of petroleum products in the forecast years is downward and the electricity consumption in the forecast years will increase over time. Azeroual et al. [12] used a time series method to estimate the long-term wind and solar energy capacity in Morocco expected around 2030, which can be injected without creating the capacity of transit constraints on the utility grid and on the entire power system. Desbois [13] used the discrete wavelet transformation technique (DWT), the integrated autoregressive moving average (ARIMA), and artificial neural network technology (ANN) to make shortterm forecasts for the city of Cape Town in South Africa. Rodrigues et al. [14] aimed to model and predict energy demand in Iran's agriculture [15]. e Box-Jenkins methodology is applied to model the agricultural consumption of four major energy sources, namely, gasoline, kerosene, diesel, and electricity, for the period from 1988 to 2014. e same data are also provided for 2015-2026 to ensure the adequacy of the model and to provide information about the state of energy demand in the Iranian agriculture in the future. e main results indicate a downward trend in the consumption of four types of energy, except for electricity is expected to increase. Mitkov et al. [16] predicted consumption energy of Islamic Republic of Afghanistan from 2001 to 2018, using the linear model ARIMA. e results showed that energy demand will continue to increase towards the end of the year 2024.

Materials and Methods
Forecasting demand is both a science and an art. Econometric forecasting methods, in the context of energy demand forecasting, can be described as the science and art of specifying, estimating, testing, and evaluating models of economic processes that determine fuel demand [2]. e majority of models operate on the basis of a macroanalysis of consumption at the level of a country or region, without distinguishing between urban and rural areas. e context is that of industrialized or emerging countries or an urban context with existing energy access [1], and the models are based on existing datasets on consumption and its potential explanatory variables. e analysis is therefore based on existing consumption with immediate needs a priori satisfied [17].
Among the prediction models, the models based on time series are the simplest. ey consist in observing past trends to predict the future. e models differ in the statistical treatments applied. In particular, ARIMA (autoregressive integrated moving average) is one of the best-known models for time series-based energy consumption prediction [1]. However, for the analysis to be valid, these models assume that data are available over a period of several decades and on the same explanatory variables. erefore, they cannot be developed in all cases, especially in some developing countries [13][14][15][16][17][18][19][20][21][22][23][24][25][26][27][28][29][30].

e Box and Jenkins Approach.
e Box and Jenkins approach (1976) is a methodology for the systematic study of time series based on their characteristics to determine, in the family of ARIMA models, the most suitable to represent the phenomenon studied [14]. e only problem with ARIMA modeling is mathematically difficult and requires a thorough knowledge of the method. It is not easy to build an ARIMA model without a statistical analysis training and knowledge of the methodology. An ARIMA model combines three types of the random process, the contribution of each being specified by the ARIMA (, d, q), where is the order of the autoregressive process AR (), d the degree of integration of a process I(d), and q the order of the moving average MA(q) [15,[17][18][19][20][21][22][23][24][25][26][27][28][29][30][31].
where μ is the average value of the sequences { y t }, L is the delay operator, . . , − ψ q L q is the polynomial of the coefficients of the moving average of order q, and ε t is the white noise with zero average [16,[18][19][20].

Identification.
e identification process autoregressive and moving averages may explain the behavior of the time series need to first verify the stationarity of the series since the basic processes, whether the autoregressive process or moving averages, are practically stationary because of constraints on their parameters. A process is said weakly stationary if its expectation and variance are constant and if its covariance depends only on the time interval. Once obtained the stationarity of the series, the next step is to analyze the graph of the autocorrelation function (CAF) and that of the partial autocorrelation function (DPF) in order to determine the parameters model (d, q) model [16].

Diagnostic.
In this final stage of the triptych identification-estimate diagnosis of the Box and Jenkins, the main checks to be performed concern the following: (i) e model coefficients must be significantly different from 0 (Student test applies conventionally). If a coefficient is not significantly different from 0, it should be considered a new specification eliminates the order of the AR model MA or invalid; (ii) Residue analysis: if the residues follow a white noise, autocorrelation does not exist in the series and residues must be homoscedastic. (iii) e model validation phase is very important and most often requires a return to the phase identification. When the model is validated, the forecast can be calculated with a time horizon of a few periods, limited because the variance of the forecast error increases very rapidly with the horizon [14].

Data and Analysis of the Results.
In this study, we used data obtained from the World Bank on energy consumption in Morocco from 1971 to 2020 in GWh, as shown in Figure 1 [32]. It may be noted that after 2000, the electricity consumption increases rapidly, which reflects the country's democratic development. Figure 1 shows that energy consumption in Morocco is a priori nonstationary. e corresponding generating process does not seem to satisfy the invariance condition of the expectation, and the same is true for the variance, i.e., energy consumption follows an upward trend and most points are not centered around zero. is implies that the series is not stationary, thus the need to perform an ADF (augmented Dickey-Fuller) test for further investigation. e ADF value at his level is −0.384570, which is higher than the critical value of the significance level of 10%, 5%, and 1%, respectively. erefore, it cannot reject the null hypothesis, for the existence of the unit root. Indeed, energy consumption in Morocco is a nonstationary time series. But the value of the ADF in the first difference is −7.084098, which is below the critical value of the significance level of 10%, 5%, and 1%, respectively. e energy consumption in Morocco is stationary in the first difference. e result shows that it is integrated in the first order, i.e., I (1). e specific results are presented in Table 1.
A first-order differential operation will be performed for the energy consumption time series. Figure 2 shows the effect of differentiation; the differentiated series no longer seems to show a trend and its volatility no longer seems to increase with time. It can also be noted that the values of the series seem to be randomly distributed on either side of the origin axis. e differentiated series thus seems stationary with a zero mean. In order to confirm this hypothesis, however, it is necessary to draw the correlograms of the differentiated series. e step that follows is to replicate the procedure of the series of energy consumption; we refer first to the correlogram of the stationary series. Figures 3 and 4 show the results of the correlation analysis. Depending on the autocorrelation coefficients and partial autocorrelation coefficients, we try to adjust a random time series. en, we judge the significance of the model, so we use the criteria of choice (log likelihood, AIC, SC, and HQC) between different models. We retain the model that has the minimum value according to the criteria AIC, SC, and HQC and the maximum value of log likelihood.
Consequently, Table 2 shows that the ARIMA (1, 1, 1) model without constant is constructed. e coefficients are significantly different from 0, and from Table 3, critical probabilities are less than 0.05. e correlogram of the residue indicates that this is a process without memory, and the correlogram of the residue squared (ARCH test) does not indicate any term significantly different from 0 as shown in Figure 5. e homoscedasticity of the residuals is therefore verified. e residuals are therefore a process of white noise as shown in Figure 6. And from Table 4, we can see that the Jarque-Bera statistic (JB � 0.916) indicates a critical probability of 0.632. us, we accept the H0 assumption of normality of the residuals. e representation is validated, and the energy consumption is an ARIMA process (1,1,1) without constant.
For a good specification of the model, it is important to test its stability, and for that, Figure 7 represents the inverses of the roots (MA and AR) characteristic of the model. We find that the points are inside the circle, that is, the ratios of the characteristic roots are all less than 1.
From Table 3, the proposed ARIMA model for forecasting electricity demand in Morocco is given as follows.
Using the estimated model, energy consumption is provided for the next 9 years. e results in Table 5 and    Figure 3: First-order differential autocorrelation correlation analysis. would continue to grow and be between 39639.09 GWh and 53589 GWh. Morocco will face a strong expansion in energy consumption due to the strategy adopted to respond to the expansion of consumption that takes the form of multiple programs aimed at optimizing the energy mix according to the reality of the market and changes affecting the conditions of supply on this market.
is uncertainty in forecast results can be explained by certain characteristics that seem likely to continue over the coming years and are located further from the demand side.

e Population Concentration.
According to a report published by the High Commission for Planning (HCP), Morocco is not immune to the trend of global demand that characterizes developing countries due to demographic pressure. e population will continue to grow, reaching 38 million in 2030, against 29.8 million in 2004. By area of residence, demographic trends will be characterized by much faster growth in urban areas due to urbanization growing and migratory flows. e urban population is expected to increase 1.5 times, from 16.4 million to 24.4 million between 2004 and 2030, which will bring the urbanization rate from 55.1% to 64.3%. is increase in urbanization will generate new urban development needs that consume energy, while preserving the growth of newer technologies such as air conditioning.

3.2.2.
e High Demand of the Transport and Industry. On the industrial side, energy needs will be substantial to support the plan "Emergence" and respond to local needs, including cement and building materials, light delays accumulated in the sector, and efforts to provide in terms of tourist and economic infrastructure.

e Growing Needs of the Rural World.
e generalization of rural electrification should lead to the development of mechanization and nonagricultural activities, which will result in an increase in energy needs.

A Growing World Economy Further Increases Energy
Demand. e world's gross domestic product (GDP), a measure of the size of the world's economy, is expected to double by 2040 with non-OECD in Asia contributing nearly 60% of that growth, particularly India and China. As economies grow, they consume more energy.
at is, as countries and their populations become wealthier, their lifestyles improve and they use more energy, whether it is to power their industries, purchase vehicles, or make greater use of electronic goods. e model developed in this article is a useful and sustainable tool for ONEE, Moroccan Ministry of Energy, and researchers, who want to study the electricity sector and produce reliable and accurate strategies up to 2030. is model can be annually updated with new macroeconomic data and have new updated forecasts.

Conclusion
Within this article, we developed an ARIMA model to model the demand forecasting electricity in Morocco by using Box-Jenkins time series approach. e historical demand data were used to develop several models, and the adequate one was selected according to four performance criteria: SBC, AIC, standard error, and maximum likelihood. As a result, we found that ARIMA (1,1,1) is the model which minimizes the four previous criteria. e results obtained prove that this model can be used for modeling and forecasting the future electricity demand in Morocco. e predictive power of this model is what pushes us to project this study at the next decade, and the main results of this projection reveal the upward trend in electricity demand, which is expected to increase from 37741.24 GWh in 2021 to 46614.04 GWh in 2030. is scenario promises an increase of almost 34.54% in case of democratic development of the country and intensified electrification of the domestic sector, as well as an industrial and agricultural development. Renewable energy plays an important role in the satisfaction of the increasing energy consumption. And bearing in mind the political situation in Morocco, the obtained results could help plan the mid-term and long-term development of the electrical network and energy generation in the country as well as create, develop, and find appropriate energy.
Data Availability e data on energy consumption per capita and average population used to support the findings of this study are collected from the World Bank.
Additional Points e data on energy consumption per capita and average population were collected from the World Bank. After multiplying between these two variables, the annual energy consumption per Moroccan population was obtained.

Conflicts of Interest
e authors declare that they have no conflicts of interest.