A Comparative Study of Stochastic Models for Forecasting Electricity Generation and Consumption in Nigeria

© 2020 The Authors. This article is licensed under a Creative Commons Attribution 4.0 License Abstract. With energy serious shortage of the Nigerian Power Sector owing to industry deregulation, abrupt variations in electricity demand, and increasing population density, Nigeria's economic development has been restricted. Thus, it is significant to balance the relationship between power generation and consumption, and further stabilize the two in a reasonable scope. To achieve balance, an accurate model to fit and predict electricity generation and consumption in Nigeria is required. This study, therefore, proposes a comparative study on stochastic modeling; (Harvey model, Autoregressive model, and Markov chain model) for forecasting electricity generation and consumption in Nigeria. The data gathered were analyzed and the model parameters were estimated using the maximum likelihood estimation technique. The comparative performance revealed that the Markov chain model best-predicted electricity generation than the Harvey and Autoregressive models. Also, for electricity consumption, results showed that the Harvey model predicted best than the Markov and Autoregressive models for electricity consumption. Thus, the Markov and Harvey model used to forecast electricity generation and consumption in Nigeria for the next 20 years (2018 to 2037) did not only reveal that electricity generation and consumption will continue to increase from 3,692.11 mln kW/h to 18,250.67 mln kW/h and from 2,961.10 mln kW/h to 127,071.30 mln kW/h respectively but also indicates high accuracy and the reference value of these models.


INTRODUCTION
The generation of electric power in Nigeria is overwhelmed by excessive demand for electricity by consumers because of inadequate supply. This supply shortfall has resulted in prolonged and intermittent power outages supplies to the consumers over the years. It is the belief that efficient power supply results in quality health care and economic growth on nation-building to mention a few [1]. Growth results in an increase in power demand, which certainly requires planning ahead of time to meet the present and future demand for uninterruptible power supply [2].
Forecasting electricity generation and consumption with high accuracy is important as it helps to plan production along with required demand in advance and prevent energy wastage and system failure. Electricity consumption forecasting is one of the most significant challenges in dealing with the supply and demand of electricity. Also, accurate forecast leads to increase the reliability of power supply, precise decision making for future development, quality savings in operation, and maintenance costs [3]. The dynamic nature of the electricity market, therefore, requires that an investor in power generation must be sure that there is a demand for electricity before setting up a generation plant, while distribution companies will want to be guaranteed that there is an available supply for their customers. Hence, a safe and reliable source of electricity involves a feasible and practical method for demand forecasting.
Many theoretical methods including growth curves, multiple linear regression methods that use economic, social, geographic, and demographic factors, and Box-Jenkins autoregressive moving average (ARMA) and autoregressive integrated moving average (ARIMA) techniques, Harvey logistic model, Harvey model, and Autoregressive model has been applied in forecasting electricity generation and consumption. Likewise, different research works have compared various models to determine which has a better forecasting accuracy. The task of ensuring power supply has become so important that researchers use various predictive models to conduct research and analysis on power in different countries. At the same time, the best estimate for the forecast of these predictive models is helpful for forecasting demand in other energy sectors. Nonetheless, there are not many shaping documents such as power prediction and accuracy comparison by using some models at the same time.
A study to determine the best model for forecasting the prices of electricity in a competitive market was shown by [4]. They compared four models; AR, MA, GARCH, and ARCH models to determine the best model and provide the estimates of electricity prices based on the best model. Other variables that provide energy in the industries were used to test the validity of the model. The models were ranked on the bases of the Akaike information criterion (AIC) and the Bayesian Information Criterion (BIC). The empirical analysis revealed that the ARMA (2,1,2) had the lowest root mean square error and the mean absolute percentage error than the GARCH (2, 1) model which indicates that the ARMA is a better model in forecasting the electricity prices than the GARCH model when there exist exogenous variables. Authors [5] used the GARCH model to estimate the volatility of the marketplace, while Harvey logistic model was used to forecast electricity demand and supply in Nigeria between 2005 and 2026. Authors [6] forecasted electricity demand in Tamale Ghana using the ARIMA model. Secondary data from 1990 to 2013 was applied, and the result showed that both domestic and commercial demand was increasing more rapidly than industrial sector demand. In [7] predicting electricity consumption using regression, the Kalman filter adaptation algorithm and ANN was investigated. Empirical results from the analysis showed that the Kalman filter adaptation algorithm was the best in terms of future prediction of electricity consumption. Authors [8] modeled and predicted residential electricity utilization in Nigeria using multiple/quadratic regression models. Empirical analysis showed that the quadratic regression model outperformed the multiple regression model. Authors [9] conducted a comparative study on medium-term load forecasting using Artificial Neural Network, (ANN) and regression model. Results showed that ANN-model performed better than the regression model for load forecasting. In [10], a study on long term electric load forecasting on the Nigerian power system using the modified form of the exponential regression model was carried out. The model was used to predict residential, commercial, and industrial load demand.
Authors [11] applied the Markov model in crude oil price forecasting. They found patterns in past crude oil price datasets that match with today's crude oil price behavior, then incorporate these two datasets with appropriate neighboring price elements to forecasting tomorrow's crude oil price. Based on a state sequence, three different states were assumed, with state-space = ( 1 , 2, 3 ), 1 =Up, 2 =Same and 3 =Down, which were decided by comparing the previous closing price and the current closing price. The number of days that both the first day and the second day are up to was calculated using data obtained on the closing index from WTI (West Texas Intermediate) for daily crude oil prices from 2nd January 2015 to 29th May 2015 to model the process. Results obtained showed that the transition matrix was stable, and the most likely trend of the index is down since the probability of down is the biggest. The previous price dated 29th May 2015 was $60.25 and the price of the predicted day, 1st June 2015 was $60.24 respectively. The result shows that forecasting is accurate and reliable. Thus, they concluded that the Markov model can produce an accurate forecast based on the description of historical patterns in crude oil prices.
In this research, three models; Harvey, Autoregressive, and Markov Chain Models will be compared on historical data of electricity generation and consumption in Nigeria and determine which of the three models has a better prediction accuracy. The model with the best fit will be used to forecast electricity generation and consumption for the next twenty years; (2017-2036).

METHODS
Autoregressive model. An autoregressive (AR) model predicts future outcomes based on the past outcome. In an AR model, the value of the outcome variable (Y) at some point in time is directly related to the predictor variable (X). It is simply a linear regression of the current value of the series against one or more prior values of the series. The value of is called the order of the AR model. AR models can be analyzed with one of the various methods, such as the standard linear least square techniques. A common approach for modeling univariate time series is the AR model: is the time series and is the white noise, with denoting the process mean.
An autoregressive model of order , denoted by AR (p) with mean zero is generally given the equation: where L is the lag operator; 1 , 2 , 3 , … . , ( ≠ 0) are the autoregressive model parameters and is the random shock or white noise process, with mean zero and variance 2 . The mean of is zero. If the mean, of is not zero, replace by − , i.e. − = 1 ( −1 + ) + 2 ( −2 + ) + ⋯ + ( − + ) + Or write, ).
An AR (p) model is stationary if the roots of ( ) = 0 all lie outside the unit circle. A necessary condition for stationary is that = 0 as → ∞. which only depends on −1 . The conditional density ( | −1 , ) is then: To determine the marginal density for the initial value 1 , recall that for a stationary AR (1) process: It follows that: The conditional log-likelihood function is: The conditional log-likelihood function has the form of the log-likelihood function for a linear regression model with normal errors. It follows that the conditional mles for and are identical to the least-squares estimates from the regression: The conditional mle for 2 and marginal log-likelihood for the initial value 1 are given by equation (5) and (6) respectively.
with exact log-likelihood function: The exact log-likelihood function is a non-linear function of the parameters , thus there is no closed-form solution for the exact mles. A Newton-Raphson type algorithm is used for the maximization which leads to the iterative scheme: is an estimate of the Hessian matrix (2nd derivative of the log-likelihood function), and ̂(̂) is an estimate of the score vector (1st derivative of the loglikelihood function). The estimates of the Hessian and Score are computed numerically using numerical derivative routines.
Prediction error decomposition. For general time series models, the log-likelihood function is computed using an algorithm known as the prediction error decomposition. To illustrate this algorithm, consider again the simple (1) model. Recall, From which it follows that The 1-step ahead prediction errors may then be defined as The variance of the prediction error at time is For the initial value, the first prediction error and its variance are Using the prediction errors and the prediction error variances, the exact log-likelihood function is re-expressed as: which is the prediction error decomposition. Further simplification is achieved by: That is * = 1 (1 − 2 ) ⁄ for = 1 and * = 1 for > 1. Thus the log-likelihood becomes

Logistic model
The Logistic model is given by (1): where is the saturation level, are parameters of the model to be estimated, is the time in years. In the Logistic model, is estimated by a Fibonacci search technique.
Differentiating equation (9) to and natural logarithms are taken on both sides, we have: Harvey logistic model. The Harvey Logistic model is based on the Logistic model. From equation (10), the Harvey Logistic model is: where is the data to be predicted at year , = − −1 , = 2…… , is a disturbance term with zero mean and constant variance, and are constants to be found by regression.
Harvey model. The Harvey model based on generally modified exponentials is of the form: The value of k determines the form of the function ( ). When = −1, ( ) is Logistic and when = 1 it is a simple modified exponential.
Differentiating and taking natural logarithm as for the Logistic model, leads to the Harvey model based on the simple modified exponential. Thus, the Harvey model is given by: , are parameters of the model to be estimated, is the error term with mean zero and constant variance.

Maximum likelihood estimation for Harvey models.
Electricity generation and consumption based on the Harvey model is generally given as: The proposed model is given as: where , are the parameters of the model to be estimated. is the error term with mean zero and constant variance. Since = − −1 , substituting for in equation (12) gives: Therefore, parameters of the Harvey model in equation (14) are estimated using the maximum likelihood method as shown below.
Taking the likelihood of equation (11), Recall the binomial expansion of (1 + ) − , However, from equation (16), (1 + ) = Still from equation (16), However, estimated parameters would then reflect in equation (14) above to become: for the appropriate prediction of electricity generation and consumption of the Harvey model.

Markov chain.
A Markov chain is a sequence of random variables 1 , 2 , 3 , …, with the Markov property namely that, the conditional probability of any future event, given any past event and the present state, is independent of the past event and depends only on the present state. In other words, the present state is only dependent on the last state and does not depend on the states before the last state.
Let denotes a random variable which represents the state of a system at time , where = 0,1,2,…… If +1 only depends on the state of , and does not depend on the states before , then: is a stationary Markov chain (or time-homogenous Markov chain). Let denotes the probability that the system is in a state at the time + 1 given the system is in state at time . If the system has a finite number of states, 1,2, … , the stationary Markov chain is defined by a transition probability matrix: where ≥ 0, , ≥ 0 and The transition probability matrix of a stationary Markov chain can be generated from the observations of the system state 0 , 1 , 2 , … , , at time = 0, … , − 1, we get the transition probability matrix as follows: = where is the number of observation pairs and +1 with in state and +1 in state ; is the number of observation pairs and +1 with in state and +1 in any state.

Maximum likelihood estimation for Markov chain.
Derivation of the MLE for Markov chains. The transition matrix, , is unknown, and we impose no restrictions on it, but rather want to estimate it from data. Given the matrix entries defined as: What we observe is a sample from the chain, x 1 = 1 , 2 , … . , . This is a realization of the random variable X 1 .
The probability of this realization is Re-write in terms of the transition probabilities , to get the likelihood of a given transition matrix: Define the transition counts ≡ number of times i is followed by in 1 , and re-write the likelihood in terms of: taking the log results in (24) Taking the derivative: = Setting equal to zero at ̂: = 0 From above, the parameters cannot all change arbitrarily, because the probabilities of making transitions from a state have to add up to 1. That is, for each , ∑ = 1.
Thus, by explicitly eliminating parameters, we arbitrarily pick one of the transition probabilities to express in terms of the others; such that the probability of going to 1, we have for each , 1 = 1 − ∑ =2 .
Taking the derivatives of the likelihood, we leave out / 1 , and the other terms will be changed: Setting this equal to zero at the MLE , Since this holds for all ≠ 1, we can conclude that ̂ ∝ , and in fact: The choice of ̂1 as the transition probability to eliminate in favor of the others is arbitrary and we get the same result for any other.
Performance evaluation of the model. This section presents statistical tools such as the coefficient of determination ( 2 ), Root Mean Square Error (RMSE), and Akaike Information Criteria (AIC) to evaluate the models discussed in the previous section.
Coefficient of determination. The coefficient of determination ( 2 ) is used to determine the effectiveness of using the model in forecasting. It is the proportion of the variance in the dependent variable that is predictable from the independent variable(s). It gives the coefficient of the total variance in the dependent variable explained by the model.
where, ̂ and are the estimated and actual value of generation or consumption of electricity data, while is the number of observations or data points. The higher the value of the coefficient of determination, the better the model.

Root mean square error (RMSE). The Root Mean
Square Error (RMSE) of an estimator measures the average of the squares of the errors or deviations. That is the difference between the estimator and what is estimated. If ̂ is a vector of n predictions, and is the vector of observed values corresponding to the inputs to the function which generated the predictions, then the RMSE of the predictor is estimated by: where, ̂ and are the estimated and actual value of generation or consumption of electricity data, while is the number of observations or data points. The lower the value of the root mean square error, the better the model.

Akaike information criteria (AIC). The Akaike
Information Criterion (AIC) is a measure of the relative quality of statistical models for a given set of data. Given a collection of models for the data, AIC estimates the quality of each model, relative to each of the other models. (32)

RESULTS AND DISCUSSION
The proposed models (Harvey model, Autoregressive model, and Markov chain model) discussed in the previous section are applied to model electricity generation and consumption in Nigeria between 1990 and 2017. The data was extracted from the archives of the Central Bank of Nigeria, and the National Bureau of Statistics. The volume of electricity generated and consumed between 1990 and 2017 constitutes the historical data set. The data set is used to compare the prediction accuracy of the three models. The models would be fitted on the historical data of electricity generation and consumption in Nigeria and the best model would be used to forecast electricity generation and consumption for the next twenty years; (2018-2037). Figures 1 and 2 show the Electricity Generation and Consumption in Nigeria. Table 1 reported the descriptive statistics of annual electricity generation and consumption.   where ̂ is the estimated electricity generation.  Table 3 and Figure 3 presents the value of the actual and estimated electricity generation.  Year Actual Predicted

Autoregressive model: Electricity consumption
From Table 4 the Autoregressive model parameters for electricity consumption is: where, ̂ is the estimated electricity consumption. The model gave 2 of 0.8494 which means that the Autoregressive model explains 84.9% of the variance in electricity consumption. The coefficient of ̂ which is 0.9492, implies that electricity consumption in Nigeria increases with time. The value of the actual and estimated electricity consumption is shown in Table 5 and Figure 4.
Year Actual Predicted

Harvey model: Electricity production
From Table 6, with 2 value of 0.9072, the Harvey model accounted for 90.7% of the variation in electricity generation. Moreover, the coefficient of is positive (̂ = 0.0155) which means that electricity generation increases with time.   Table 7 and Figure 5 present the actual and predicted value of electricity generation based on the Harvey model.
Year Actual Predicted

Harvey model: Electricity consumption
From Table 8, with 2 value of 0.9485, the Harvey model accounted for 94.85% of the variation in electricity consumption. Moreover, the coefficient of is positive (̂ = 0.1979) which means that electricity consumption increases with time.   Table 9 and Figure 6 present the actual and predicted value of electricity consumption based on the Harvey model. Table 9 -Actual and Predicted Electricity Consumption Using the Harvey model, mln kWh
Electricity Generation. Below is the transition matrix of electricity generation defined by the following states: Very Low, Low, Middle, High, Very High The transition matrix defined as follows: Very   Table 11 and Figure 7.  The value of the actual and estimated electricity consumption using the Markov chain is shown in Table 13 and Figure 8.    The forecasting of electricity generation is obtained from the Markov chain model by extrapolating the data from the year 2018 to 2037. Table  15 shows the forecast for electricity generation in Nigeria using the best-selected Model (Markov Chain Model). The forecast values in Table 15 and Figure 9 indicate that electricity generation in Nigeria is continuously increasing. Electricity generation in Nigeria will increase from 3,692.11 mln kW/h in 2018 to 18,250.67 mln kW/h in 2037.      Table 17 and Figure  10 indicate that electricity consumption in Nigeria is continuously increasing. Electricity consumption in Nigeria will increase from 2,961.10 mln kW/h in 2018 to 127,071.30 mln kW/h in 2037.

CONCLUSION
Forecasting electricity generation and consumption is an important component of the electricity market, as it helps to plan production along with required demand and to prevent energy wastage and system failure. This paper has investigated the effectiveness and validation of three different models; Markov chain, Harvey, and Autoregressive models in modeling electricity generation and consumption in Nigeria. From the analysis performed, it was discovered that the coefficient of is positive which means that electricity generation and consumption increases with time. There is strong evidence in favor of the fact that there is an increase in demand and consumption of electricity in Nigeria. Again, modeling historical data on generation and consumption was better explained by the Markov chain model for the generation data and Harvey model for the consumption data. This corresponds to what can be observed from the time series plot in Figures 9 & 10 respectively, which shows the trend in generation and consumption of electricity. The Markov chain and Harvey models also performed better in the prediction of electricity generation and consumption. Hence, the two models are better for describing generation and consumption volume of electricity respectively.
Based on the results obtained from Markov and Harvey models in predicting generation and consumption of electricity, we can conclude that the demand for electricity in Nigeria will maintain an upswing over time. This is evident in the historical data which shows that generation and consumption have majorly been on the increase yearly.