The previous sections have described in detail the steps required to develop a time series forecast including: how to generate useful explanatory variables; how to train the model; how to avoid overfitting; and how to evaluate the accuracy of the model. What has not been investigated is the models themselves. This chapter will be the first of three chapters looking at a wide range of models and some of their properties.
This chapter and the next will look at point forecast methods, and then in Chap. 11, probabilistic forecasts will be examined which provide models for handling highly uncertain data, something which is often required for low voltage feeders and substations (Chap. 2).
Of the point forecasting chapters, this chapter looks at traditional statistical methods, whereas Chap. 10 will look at what are sometimes referred to as machine learning models. Each type of models has advantages and disadvantages, some of which have already been described in Sect. 5.3, but further criteria will be described in Sect. 12.2. In short, statistical models are typically more transparent and easier to interpret and understand. That makes them not only useful for investigating some of the core features of the data, but also makes them good benchmark candidates.
The majority of the models presented in this chapter are easily implemented through packages in open source programming languages for scientific computing such as Python and R as well in popular proprietary software such as MATLAB. However they can be easily derived and trained from scratch (since they are often linear functions and hence can be easily trained using e.g. linear least squares, see Sect. 8.2), which may be preferable when you want to extend the models or make bespoke adjustments.
This chapter starts by considering some simple models and then introduces progressively more complicated ones (in terms of more parameters and computational expense) starting with exponential smoothing (Sect. 9.2), multiple linear regression models (Sect. 9.3), ARIMA and SARIMA models (Sects. 9.4 and 9.5 respectively), and then finally generalised additive models (Sect. 9.6).
Before diving into the models it is worth highlighting the context for these forecasts: short term load forecasts (STLF). A common way to categorise a load forecasts is in terms of the forecast horizon. Short term forecasts estimate the demand between a day and a week ahead (sometimes two weeks). In contrast, those from 1 week up to a year are referred to as medium term load forecasts, and those beyond a year, long-term load forecasts. Note these definitions can vary slightly depending on the context but are typically in the ranges specified. Models which are good for STLF may not be suitable for medium and long term load forecasts, and vice-versa. Hence the models presented here are specifically chosen for their use in shorter term load forecasts which will usually heavily rely on the most recently observed information.
9.1 Benchmarks Methods
This section will begin with considering basic and commonly used benchmark methods. As discussed in Sect. 8.1.1 developing appropriate benchmarks is essential for any well-designed forecast experiment. As usual throughout this chapter a time series of the form $L_1, L_2, \ldots ,$ will be considered and the aim is to produce estimates $\hat{L}_{N+k}$ for the time steps $N+k$ where $N \in \mathbb {N}$ is the forecast origin and $k \in \mathbb {N}$ the forecast horizon (See Sect. 5.2 for further details on these terms).
Persistence: $\hat{L}_{N+1} = L_{N}$
This model assumes that the demand of the next time step is simply the current load. Additional future time steps can be estimated by simply repeating this value.
Seasonal persistence: $\hat{L}_{N+k} = L_{N+k-s_1}$

The plot shows a simple persistence forecast (grey flat line) and a daily seasonal persistence (red line) for the fourth day of the half hourly data. The observations are shown as a black line. The data in this example has daily seasonality and hence the seasonal persistence model picks up important features of the data
Seasonal Moving Average (SMA): $\hat{L}_{N+k} = \frac{1}{p}\sum _{i=1}^{p}L_{N+k-i s_1}$.

Plot shows a daily seasonal moving average forecast (blue line) over three historic days to generate a forecast for the fourth day of the half hourly data. The observations are shown as a black line. The data in this example has daily seasonality but more volatile data on the third day of the data. Hence in this case the daily seasonal persistence would not produce an accurate forecast for the fourth day compared to the simple moving average which smooths out the errors over the three days
As with the seasonal persistence, often a weekly period ($s_1=336$ for half hourly data) is used. The weekly simple averages often perform much better than the equivalent seasonal persistence models since it smooths out the random week-to-week aberrations around the expected value and therefore better replicates the typical weekly behaviour. An example is illustrated in Fig. 9.2 for daily seasonal data. Day 3 had unusually large demand, hence a daily seasonal persistence model would not be as accurate as when it was used in the previous example in Fig. 9.1. Instead the simple average over the Days 1–3 reduces the effect of the unusual day 3 and hence provides a better estimate of day 4. For the simple average method, slightly more training data is required than the persistence models, and in addition a validation period is required to choose the most appropriate value of the hyperparameter p (Sect. 8.1.3). However, the model is very quick to calculate and in practice typically only requires setting $p=4$ or 5 weeks to optimise the model and offer significant improvements over the persistence models.
9.2 Exponential Smoothing
Despite their simplicity, the benchmarks introduced in Sect. 9.1, especially the seasonal moving average, can be surprisingly accurate. However, one of their disadvantages is that each historical week they utilise is given equal weighting whereas it would be expected that older data is less relevant to the current forecast period. In other words, older data should contribute less than more recent data to the final forecast. This is particularly relevant for load data as it is strongly driven by seasonalities and trends. For example, it would be expected that data from a few months ago in, say summertime, is less relevant to the winter period.

Simple example of exponential smoothing for different values of the smoothing parameter
To illustrate the exponential smoothing method consider a basic example given in Fig. 9.3. Two exponential models are applied using two different values of $\alpha$ to produce a 1-step ahead forecast. The model that uses $\alpha =0.7$ is less smooth and is driven mainly by the most recent points. The model that uses $\alpha =0.2$ is the smoothest and takes a weighted average which has more contributions from older historical values. In this case less smoothing (higher $\alpha$ value) is more useful for prediction since the data has a decreasing trend and hence older points are much less relevant to the recent data.
Training the model parameters can be achieved by numerical optimisation of the one-step ahead, sum of squared errors (i.e. Eq. (8.5)) over the training data (Sect. 8.2) as before. However, note that there must be an initial estimate for the level and seasonal components before the parameters can be trained. There a few ways to do this but a simple method is to take an average over the oldest observations to ensure that there is initial data to train the algorithm. An example of the double seasonal exponential smoothing model will be given in the case study in Sect. 14.2.
9.3 Multiple Linear Regression

Linear regression line $Y=(X-2)^2+1.2 = X^2 - 4X + 5.4$ (black) and noisy, Gaussian observations (red crosses) around the line
As an example, consider the situation in Fig. 9.4 where the best regression fit for the observations (in red) is the curve $Y=(X-2)^2+1.2 = X^2 - 4X + 5.4$. Notice, that although the function contains a quadratic term $X^2$, it is still clearly linear in the coefficients with independent variables $\textbf{X} = (X^2, X, 1)^T$ and corresponding regression parameters $\boldsymbol{\beta }= (1, -4, 5.4)^T$. Hence it is important to understand that nonlinear relationships can still be modelled within linear regression. For an example in demand forecasting, notice that the nonlinear relationship between demand and temperature in Fig. 6.7 in Sect. 6.2.2 could be modelled by a linear regression using a polynomial (if chosen with sufficient order).
Another useful feature of linear regression is that we can include interaction terms. This is where we model the effect of two or more variables on the dependent variable. For example, it may be that temperature $T_k$ has an effect on demand, but only for a particular hour of the day, say 2–3 pm. In this case we can include a term for the temperature variable but multiplied by a dummy variable which indicates the time of day and is zero at all times except the hour 2–3 pm. In the linear regression the interaction term is often denoted as multiplication of the two terms, e.g. $T_k D_j(k)$ or $T_k * D_j(k)$. The case is similar if the simultaneous effect from more than two variables are modelled. An example of interaction terms in a linear regression model will be given in the case study in Sect. 14.2.
Given the assumptions on the errors, the coefficients of a linear regression model are often found by minimising the least squares estimate (see Sect. 8.2) and are therefore quite easy, and quick, to train. Recall, that since the errors are assumed to be Gaussian with constant variance, the least squares estimate of the model are also the maximum likelihood estimate as shown in Sect. 8.2. This is particularly convenient since the loglikelihood (see Eq. (8.8)), and hence the Bayesian information criteria (BIC) and Akaike information criteria (AIC), are both easy to calculate. Recall from Sect. 8.2.2, that identifying the models with the smallest values of AIC or BIC is one way to choose the best models on the training data, which have a tradeoff between accuracy and model complexity helping to limit the potential for overtraining the models.
As described in Sect. 8.2.2, linear models can be easily adapted to regularisation frameworks such as LASSO and ridge regression. Much like the AIC and BIC these techniques penalise the number and/or size of the coefficients by including a penalty term on the normal least squares regression. In particular LASSO can be used as a model selection technique as it tends to set the coefficients of irrelevant (or less influential) explanatory variables to zero. Finally, of course, as with all the methods, the models can also be selected through cross-validation and finding the model which minimises the error on the validation set. This can be quite inefficient if there is a lot of independent variables being considered.
Given the final trained model, the simple linear structure the coefficients provide a useful way to interpret the effect of each variable (assuming they are independent). Essentially they tell you how much the expected value of the dependent variable will change given a unit change in the independent variable assuming all the other independent variables are fixed. The interpretation becomes a little more complex when there are interaction terms as the effect size will now be dependent on the value of the other variable(s). In these cases inserting a range of reasonable values for these other variables may help to show the range of effects.
9.4 ARIMA and ARIMAX Methods

Example of autocorrelation (top) and partial autocorrelation (bottom) for a simple AR(4) model
In contrast, moving average models are influenced by past values of the error values, so large past deviations can have an influence on the current time series values. One of the useful properties of a pure MA(q) process is that the autocorrelation function should be zero from lag $q+1$ onwards. So the ACF plot can be used to identify a MA time series and its order. It should be noted that, although the ACF and PACF can be used to identify AR and MA models and their orders, in practice the sample version of these functions are used, applied to real observed data, and hence the results may deviate from the more clear-cut theoretical solutions. In other words the autocorrelations may exceed the confidence bounds but these may be spurious and simply occur due to random chance.
Check if the time series is stationary. If it isn’t perform differencing until the final series is stationary. Stationarity can be checked in many ways. In addition to a time series plot, another indication of non-stationary time series is a slowly decaying auto-correlation function as a function of lags (see Chap. 3). However, there are also stationarity tests as outlined in Appendix A.
Identify the orders of the autoregressive (AR) and moving average (MA) terms. This can be estimated by examining the autocorrelation function (ACF) and partial autocorrelation function (PACF) plots (see Chap. 3 and Sect. 6.2.4). In particular, if the model has an AR component of order p then the PACF should be effectively zero from lag $p+1$ and above. Similarly for an MA model of order q, the ACF should effectively be zero from lag $q+1$ and higher. In practice these orders can be found by looking at the respective plots and considering whether they are above the $95\%$ confidence interval (which are usually included on the plot, see Sect. 6.2.4).
Using the ACF and PACF as an approximation for the correct orders, check the AIC (or BIC) values for a selection of ARIMA models with different p, d, q values (around the approximate values). The final orders are those that give the smallest AIC (BIC) values.

Example time series, generated from the ARIMA(3, 0, 1) model $y_t = 0.14+0.609y_{t-1}-0.5y_{t-2}+0.214y_{t-3}+0.624e_{t-1}+e_t$

ACF (top) and PACF (bottom) plot for the time series $y_t = 0.14+0.609y_{t-1}-0.5y_{t-2}+0.214y_{t-3}+0.624e_{t-1}+e_t$
The Box-Jenkins methodology is illustrated here for a specific example using an ARIMA(3, 0, 1) (or equivalently an ARMA(3, 1)) model given by $y_t = 0.14+0.609y_{t-1}-0.5y_{t-2}+0.214y_{t-3}+0.624e_{t-1}+e_t$. The time series is shown in Fig. 9.6 and was generated using the Matlab simulate function.2 The $e_t$ is the error series which are distributed according to the standard normal distribution. In this case the series is stationary so there is no differencing required. To check the autoregressive and moving-average orders the ACF and PACF plots are considered, these are shown in Fig. 9.7, together with the confidence bounds for the $95\%$ significance level. The ACF (the top plot) indicates the MA order and shows that the largest correlation is at lag 1, which is as expected, however there are also significant correlations (significant in terms of being clearly outside of the confidence interval) at lags 16 and 17. Notice that the ACF doesn’t gradually decrease as a function of lag, this supports the conclusion that the time series is stationary. The PACF indicates the AR order and in this example shows there are significant peaks at lags 1–4 which suggest a slightly larger order than expected. In addition there are smaller peaks outside the confidence interval at larger lags as well. This analysis indicates that ACF and PACF analysis is limited in terms of giving a complete answer to the exact order. In fact, the plots have limitations as it would be expected that $5\%$ of autocorrelations to be outside of the confidence interval by random chance anyway. This means that the ACF and PACF must be interpreted with caution and in conjunction with the AIC.
Akaike Information Criterion results for different AR (p) and MA (q) values for the ARIMA example given in the text
q value | |||||
|---|---|---|---|---|---|
1 | 2 | 3 | 4 | ||
p value | 1 | 67.90 | 56.03 | 56.67 | 54.83 |
2 | 53.95 | 53.39 | 52.00 | 52.04 | |
3 | 50.45 | 52.34 | 52.13 | 53.19 | |
4 | 52.34 | 53.72 | 54.90 | 56.25 | |
It should be noted that any MA model can be estimated by an AR model with a sufficiently large number of lags (p value). Since the coefficients of an AR model can be calculated much more quickly than a full ARIMA model, it can be preferable to replace any ARIMA model with an AR (with differencing if not stationary) with large enough degree. This can also simplify the analysis and interpretation of the models. However, this may also require a relatively large order and thus many more parameters in the AR model compared to a simple ARMA model, reducing parsimony and interpretation.
9.5 SARIMA and SARIMAX Models

Example of a ARIMA$(2,0,0)(1, 0, 0)_{10}$ series (top), and the corresponding PACF
For more details on ARIMA and SARIMA models check out [2] as well as other literature listed in Appendix D.
9.6 Generalised Additive Models
The linear models specified in Sect. 9.3 have various limitations. The two strongest and most common assumptions are that the errors follow a Gaussian distribution and that the model is a simple linear combination of various input variables.
GAMs have several advantages over GLMs, firstly the functions $f_k$ allow the modelling of a much more diverse set of, possibly nonlinear, relationships whereas GLMs are only of the form $f_k(X_k, {N+1}) = \beta X_{k, N+1}$. In addition, these functions are often modelled nonparametrically, whereas the GLMs often assume parametric transforms and distributions (GAMs can also utilise common parametric forms as well, e.g. log functions, or polynomials for each $f_k$). Note that GAMs still use a link function g which can be used to transform the dependent variable into a more suitable form for training.

Example of linear spline (top) and cubic spline (bottom). The squared markers are the knots which the polynomials interpolate
For GAMs, it is common to choose splines for these basis functions. A spline is a piece-wise continuous function which is composed of other simpler polynomial functions. One of the simplest examples of a spline is a piecewise linear combination. Examples of a linear and a cubic spline is shown in Fig. 9.9. Note since a spline is continuous, the end of one polynomial must join on the start of the next polynomial. The knots specify where the polynomials join to each other. The cubic version is regressed on the observations (red points) between the knots to determine the other two coefficients in each cubic polynomial (two of the coefficients are already found by the interpolation constraints).

Example of a smooth cubic spline interpolated through the same points as in Fig. 9.9
Other constraints can be applied to the spline to either make it easier to train or to satisfy other criteria. One of the most common requirements for a GAM is to ensure that the spline has a particular level of smoothness. As can be seen the cubic interpolation in Fig. 9.9 is smooth between the knots but not across the knots themselves. Constraining the cubic spline to be smooth whilst interpolating across the knots means all coefficients can be determined uniquely. Another way of saying the spline is smooth is to say that the derivative (up to a sufficient order) is continuous at the knot points. An example of a cubic spline which is smooth across the knots is shown in Fig. 9.10.
Note that the aim in forecasting is to regress on the data, and therefore it is not necessary (or desirable) to strictly interpolate through the observations. However, the principle is still the same and the final spline should be continuous throughout, including at the knots.5 This is achieved by regressing the basis version of the relationship on the observations (See Eq. (9.17) above).
Certain basis functions, such as B-splines have very desirable properties such as providing smoothness at the knots. Further, although the number and type of the basis functions should be sufficiently flexible to fit the data, without any additional constraints or regularisation (Sect. 8.2.4) large numbers of knots and high polynomial degrees will increase the chance of overfitting to the noise. In addition, this will mean the polynomials will be very “wiggly”. To prevent this, one approach is to include an extra term which is often added to penalise the lack of smoothness in the final solution. Recall this is much like the LASSO (Sect. 8.2.4) method and other regularisation techniques used to preventing overfitting.

The additive nature of the GAMs model makes the model interpretable since the contributions of individual features and interactions can be analysed and visualised, even if complex nonlinear functions are used. Figure 9.11a and b show exemplary visualisations of the contribution of individual terms to the final prediction. Figure 9.11a shows the weekday ($W_k$) contribution to the demand, indicating that for the specific model, the load is much lower on weekends and is highest on Thursdays. Figure 9.11b shows the combined effect of the interaction of the hour of the day ($H_k$) and outside temperature ($T_k^{out}$), for example, influence is lowest over night and for cold temperatures and highest around noon for high temperatures. Plots of the smaller subsets (typically one or two) of the full input variables are called partial dependence plots and allow us to examine, and better interpret, the overall effects of the different components.
There are a whole host of different approaches and parameters to choose and many GAM programming packages, such as gam or mgcv in R and pygam in python,6 work for a selection of splines, smoothing parameter selection methods, and link functions. Often these packages will have their own default settings but in many cases these can be tweaked to ensure a more accurate fit and better performance. In particular if it is known that the errors are not Gaussian, or that a particular independent variable only has a linear relationship to the dependent variable, then these can be specified when implemented. Other parameters or data assumptions should also be checked, but if you are uncertain then several values can be checked via cross-validation methods. Since regularisation is employed within most packages it is better to have more degrees of freedom specified by the splines than too few. As usual residual checks (Sect. 7.5) can be used to evaluate the final models and identify incorrect assumptions or areas of improvement.
Note that there may be additional constraints applied to the basis/spline functions to better model the features in the demand data. In particular, since there is often periodicity in many of the dependent variables (e.g. hour of the day or week), basis functions can be chosen to include these features, e.g. periodic B-splines which are available for some of the aforementioned packages.
The above is a basic introduction to GAMs and a more detailed description for a very complicated area is beyond the scope of this book. Some further reading is included in Appendix D.2.
9.7 Questions
For the questions which require using real demand data, try using some of the data as listed in Appendix D.4. Preferably choose data with at least a year of hourly or half hourly data. In all the cases using this data, split it into training, validation and testing with a 3 : 1 : 1 ratio (Sect. 8.1.3).
Select a demand time series. Analyse the seasonalities, (see Sect. 6.2). Generate some simple benchmark forecasts for the test set, including the persistence forecast, and seasonal persistence forecasts, one for each seasonality you found. Calculate the RMSE errors. Which one is lower? How does this compare with the seasonalities you observed? Compare these results to the ACF and PACF plots for the time series.
Continuing the experiment from the previous section generate seasonal moving averages using the identified seasonalities. Using a validation set (Sect. 8.1.3) identify the optimal value of seasonal terms, p, to include in the average. If there is multiple seasonalities which one has the smallest errors overall? How does the RMSE error on a test set for the optimal seasonal average forecasts compare to the persistence forecasts in the previous question?
Generate a simple 1-step ahead exponential smoothing forecasts (Sect. 9.2) for a load forecast time series (preferably one which has double seasonal patterns, usually daily and weekly). Manual select different values of the smoothing parameter, $\alpha$. Plot the RMSE errors against the smoothing parameters. Do a grid search to find the optimal smoothing parameter (Sect. 8.2.3). How does the optimal forecast compare to a simple persistence forecast? Now consider the Holt-Winters-Taylor forecast and perform a grid search for the four parameters $\phi , \lambda , \delta , \omega$.
Investigate a LASSO fit for a linear model. Set the coefficients of a model with a few Sine terms, e.g. $\sum _{k=0}^N \alpha _k \sin {k x}$, for N about 5, and $x\in [0, 4\pi ]$. Sample 20 points from this data (and add a small amount of Gaussian noise). Now fit a multiple linear equation of the form $\sum _{k=0}^{50} \gamma _k \sin {k x}$ using least squares regression to find the coefficients $\gamma$. Now plot the trained model on 20 new $x \in [0, 4\pi ]$ values. Is it a good fit? Now try and minimise the LASSO function using different values of the regularisation parameter $\lambda$ (See Sect. 8.2.4). How does the fit change as you change the parameter? How many coefficients $\gamma$ are zero (or very small). Use inbuilt functions to do the LASSO fit such as sklearn7 in Python, or glmnet8 in R.
Show for the basis representation for GAMs, that the second order penalty term (9.20) takes the form $\boldsymbol{\alpha }_k ^T \textbf{S}_k \boldsymbol{\alpha }_k$
Try and generate a linear model that fits a demand profile. Consider what features to use, if time of day is important considering using dummy variables. If weather data is available check if there is a relationship with the demand (see Chap. 14). In the case study in Sect. 14.2 a linear model will be generated for modelling the low voltage demand. Come back to this question once you’ve reached that part of the book and see what similarities there are. What have you done differently? What would you like to change in the model? Fit the linear model using standard packages in Python and R such as sklearn9 and lm10 respectively. Now using the same features implement a GAM. Again these forecasts can be trained using standard Python and R packages such as pygam11 and mgcv12 respectively. These packages often have similar syntax to the linear models. Now compare the forecasts and the errors. For the GAM look at the partial dependency plots. What is the relationship for each variable chosen.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.