#### Abstract

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.

#### 1. 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. The 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.

This 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.

The 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.

#### 2. 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 emissions during the period 1960–2017, using ARIMA (Jenkins–Box) methodology, and the study led to the selection of the best model for predicting 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 emissions in China over the next ten years, as the proposed model expects the total annual 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 Thailand, Sutthichaimethee [7] analysed 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 emissions in Thailand. Employing a novel bioinspired framework, Sangeetha and Amudha [8] predicted 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. They 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. The 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 short-term 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]. The 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. The 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. The 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. The results showed that energy demand will continue to increase towards the end of the year 2024.

#### 3. 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]. The 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. The 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. The 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. They consist in observing past trends to predict the future. The 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. Therefore, they cannot be developed in all cases, especially in some developing countries [13–30].

##### 3.1. The Box and Jenkins Approach

The 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]. The 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–31].

where *μ* is the average value of the sequences {}, *L* is the delay operator, , is the polynomial of the autoregressive coefficients of order , is the polynomial of the coefficients of the moving average of order *q*, and is the white noise with zero average [16, 18–20].

###### 3.1.1. Identification

The 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].

###### 3.1.2. 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)The 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)The 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].

##### 3.2. 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. The 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. This implies that the series is not stationary, thus the need to perform an ADF (augmented Dickey–Fuller) test for further investigation. The 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. Therefore, 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. The energy consumption in Morocco is stationary in the first difference. The result shows that it is integrated in the first order, i.e., I (1). The 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. The 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.

The 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.

Then, 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.

The coefficients are significantly different from 0, and from Table 3, critical probabilities are less than 0.05.

The 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.

**(a)**

**(b)**

The homoscedasticity of the residuals is therefore verified. The 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. Thus, we accept the H0 assumption of normality of the residuals. The representation is validated, and the energy consumption is an ARIMA process (1,1,1) without constant.

**(a)**

**(b)**

**(c)**

**(d)**

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.

**(a)**

**(b)**

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. The results in Table 5 and Figure 8 show that by 2030, the annual energy consumption 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.

This 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.

###### 3.2.1. The 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. The 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. The 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%. This 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. The 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.

###### 3.2.3. The Growing Needs of the Rural World

The generalization of rural electrification should lead to the development of mechanization and nonagricultural activities, which will result in an increase in energy needs.

###### 3.2.4. A Growing World Economy Further Increases Energy Demand

The 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. That 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.

The 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. This model can be annually updated with new macroeconomic data and have new updated forecasts.

#### 4. Conclusion

Within this article, we developed an ARIMA model to model the demand forecasting electricity in Morocco by using Box–Jenkins time series approach. The 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. The results obtained prove that this model can be used for modeling and forecasting the future electricity demand in Morocco. The 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. This 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

The 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

The 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

The authors declare that they have no conflicts of interest.