Can We Predict the Day Ahead Electricity Market?
By: Hamza Hamud
Tags: Arima, Time Series Analysis, Python, Forecasting, Data Science

Can We Predict the Day Ahead Electricity Market?

Nordpool operates the day ahead electricity trading platform for the UK, Nordic and Baltic states. The day ahead market operates by setting up a supply and demand equilibrium, so a consumer will enter into the system the volume of electricity required and the price willing to be paid on an hourly basis and the generator will need to determine how much electricity it can deliver and what price it wants on an hourly basis. The price of electricity is determined by the system matching up offers from generators of electricity to bids from consumers. Purchasing and selling curves are constructed and the point where they cross determines the market price and the volumes of electricity that is traded on the hour every day.

The ARIMA forecasting method will be used to predict the day ahead electricity market. I opted to use non-seasonal ARIMA method due to only using the first 300 values in total rather than the entire year of data. The data is from Nordpool for the year 2016 — 2017 and only 300 values out of the potential 8800 values were used for this process due to the model taking too long to run on my computer. Full code for this process is in the GitHub repository

Fitting the Forecasting Model

ARIMA stands for AutoRegressive Integated Moving Average and in this model, there are three main parameters used represented as (p,d,q). This model combines the autoregressive model and the moving average model and applies this mixed forecasting model to a differenced time series.

The first step is to see if the time series is stationary or not meaning checking to see if the statistical properties of the time series varies with time. The test to use is called the Augmented Dickey — Fuller test which is also called the unit root test. It tests the null hypothesis that a unit root is present in a time series sample, that it is not stationary and the alternative hypothesis is that it is stationary in that its statistical properties do not vary over time.

Dickey-fuller Test Code

Results of the Dickey-Fuller Test

The results indicate that null hypothesis can be rejected as it is statistically unlikely that the data sample is non stationary as the p-value < 0.0000001 meaning that there is no unit root present in the data sample and therefore the time series is stationary.

The d parameter represents the integrated order of differencing required of the model such that the time series data becomes stationary. The time series is made stationary by subtracting the present observation from an observation from a previous time step. So in this case, it can be set to 0 as the time series is already stationary.

The P parameter represents the order of the autoregressive model of the ARIMA method. This uses the dependent relationship between an observation and a number of lagged observations, meaning that this is a tool used to test for randomness within the time series data by testing to see how much of X is affected by the previous values of X. e.g. How much of the current price is dictated by the previous prices and how much further back does this go. This parameter is calculated by creating an autocorrelation chart and looking at the number. In this case, from the chart, it can be set to order 5.

Autocorrelation chart that helps to determine the P Parameter

The q parameter represents the order of the moving average and shows the size of the window function as it moves. This parameter is calculated from the partial autocorrelation chart. In this case, it can be set to order 12 as there are 12 values outside of the 95% confidence interval, (the blue strip).

Partial autocorrelation graph that helps to determine q parameter

Here is the code for testing out different ARIMA models and calculating which has the lowest AIC value. The AIC value is the Akaike information criterion and compares the forecasting models to each other. As it is very difficult to see the correct parameters from the plots above, I have also opted to iterate through a range of ARIMA models to see which has the best

Iterating the ARIMA forecasting models

The result of the code above gave us a model of (1,1,2) to use for the (p,d,q) parameters with an AIC value of 1400, there other different models with lower values however they were throwing up errors, therefore I will be using these values as it is difficult to detect the correct AR and MA parameters from the plots alone.

Validating the model

Now that the ARIMA parameters have been found, the data must be split into training and testing samples so the first 200 values will be used to train the model on and the last 100 values will be used to validate the model.

Arima forecasting function written to predict the next 100 values

The results are shown below and the majority of the test values are within the 95% confidence interval of the predicted ARIMA values. The mean squared error of the model is 62 which indicates that the model can be further improved. However, our initial endeavour is successful and that you can predict the day ahead markets using the ARIMA model.