1 Introduction

1.1 Data Description

ENTSO-E Transparency Platform gives access to electricity generation, transportation, and consumption data for the pan-European market. Part of this data is provided by the various transmission system operators (TSOs) accross Europe.

Western Europe Consumption data has been retrieved for each of the following countries : Austria, Belgium, Switzerland, Denmark, Germany, Spain, France, UK, Italy, Ireland, Luxembourg, the Netherlands, Norway, Portugal, and Sweden. The time resolution is either 15 minutes, 30 minutes or 1 hour depending on the country.

The consumption is given in Megawatts (MW) and goes from January 2015 up to August 2020.

[https://www.kaggle.com/francoisraucent/western-europe-power-consumption?select=fr.csv]

1.2 What we do

In this opportunity we will choose two different country from western Europe to be observe on a daily power consumption given in Megawatts using time series modeling.

2 Austria Power Consumption Analysis in Time Series

2.1 Library Set up

library(tidyverse) #data manipulation
library(lubridate) # date manipulation
library(forecast) # time series library
library(TTR) # for Simple moving average function
library(MLmetrics) # calculate error
library(tseries) # adf.test
library(fpp) # usconsumtion

2.2 Read Data

# Power consumption in Austria
austria <- read.csv("at.csv")

head(austria)
austria <- austria %>% 
  mutate(start = ymd_hms(start))

Column description :

  • start : The beginning time of each time interval (every 15 minutes)

  • end : The end of each time interval

  • load : Power consumption in Megawatts

2.3 Data Aggregation

# Aggregate

austria_agg <- austria %>% 
           select(start,load)

2.4 Data Pre-procesing

2.4.1 Impute Missing Records

library(padr)

austria_agg <- austria_agg %>% 
  pad()
library(zoo)

austria_agg <- austria_agg %>% 
  mutate(load = na.fill(load, fill = "extend"))

2.4.2 Feature Engineering & Data Aggregation

In this case i will convert the data from minutes interval into daily interval data of power consumption and analyze it as time series object.

This will remove the hourly effect on hourly load, but it is a practical strategy for power supplier or any other parties that need to see energy consumption on a daily basis.

daily_austria <- austria_agg %>% 
  mutate(year = year(start),
         month = month(start),
         day = day(start),
         date = paste0(year,"-",month,"-",day),
         date = ymd(date)) %>%
  select(-start, -year, -month, -day) %>% 
  group_by(date) %>% 
  summarise(load = sum(load))
daily_austria
range(daily_austria$date)
#> [1] "2015-01-01" "2020-07-31"

2.5 Create Time Series Object and EDA

In this section, I tried to explore whether our timeseries object has trend and seasonal properties (one-seasonal/multiseasonal).

# Initial time series object

austria_ts <- ts(data = daily_austria$load,
                 start = range(daily_austria$load)[[1]],
                 frequency = 7)
# decompose time series for austria into object

austria_dc <- decompose (austria_ts)

autoplot(austria_dc)

Based on the plot, the trend still shows a pattern of ups and downs which indicates a multiseasonal time series object. Therefore, we should try reanalyze this data through multiseasonal time series using monthly.

daily_austria$load %>% 
  msts(seasonal.periods = c(7,7*4)) %>% # multiseasonal ts (weekly, monthly)
  mstl() %>% # multiseasonal ts decomposition
  autoplot()

Based on the plot there is still pattern in trend, Therefore, we will add another seasonal frequency in yearly.

daily_austria$load %>% 
  msts(seasonal.periods = c(7*4,7*4*12)) %>% # multiseasonal ts (monthly, yearly )
  mstl() %>% # multiseasonal ts decomposition
  autoplot()

The above graphic is showing the best decomposition among other trail. Therefore, we will use this ts object for our modelling.

# assign final ts object

## Austria
austria_msts <- daily_austria$load %>% 
  msts(seasonal.periods = c(7*4,7*4*12))

2.6 check for stationary

adf.test(austria_msts)
#> 
#>  Augmented Dickey-Fuller Test
#> 
#> data:  austria_msts
#> Dickey-Fuller = -4.5463, Lag order = 12, p-value = 0.01
#> alternative hypothesis: stationary

Based on Augmented Dickey-Fuller Test (adf.test) result, the p-value is < alpha and therefore the data is already stationary. Therefore, for a model building using SARIMA, we do not need to perform differencing on the data first.

2.7 Cross Validation

The cross-validation scheme for time series should not be sampled randomly, but splitted sequentially.

We will create the data test from the last three month of data

austria_train <- austria_msts %>% head(length(austria_msts) - 7*4*3)
austria_test <- austria_msts %>% tail(7*4*3)

2.8 Model Building

In this opportunity i will use Holt-Winters and ARIMA Modelling and compare which one of the them is having the better result

# ets Holt-Winters
austria_ets <- stlm(austria_train, method = "ets", lambda = 0) 

# SARIMA
austria_arima <- stlm(austria_train, method = "arima", lambda = 0)

2.9 Forecast & Evaluation

# forecast power Austria
austria_ets_forecast <- forecast(austria_ets, h = 7*4*3)
austria_arima_forecast <- forecast(austria_arima, h = 7*4*3)

austria_ets_forecast
#>          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
#> 6.818452       521220.1 486519.6 558395.6 469095.4 579136.7
#> 6.821429       484492.6 450513.8 521034.3 433502.0 541481.1
#> 6.824405       561105.8 519864.5 605618.8 499274.3 630594.7
#> 6.827381       612543.2 565559.4 663430.1 542164.6 692057.7
#> 6.830357       610387.3 561701.6 663292.8 537521.2 693131.0
#> 6.833333       614748.6 563912.6 670167.4 538726.2 701499.0
#> 6.836310       591839.3 541229.7 647181.4 516214.7 678542.9
#> 6.839286       530876.9 484038.2 582248.1 460940.0 611425.0
#> 6.842262       499016.7 453679.5 548884.5 431371.5 577269.6
#> 6.845238       625706.2 567269.9 690162.3 538578.3 726929.2
#> 6.848214       597036.4 539807.5 660332.6 511767.5 696512.4
#> 6.851190       621040.4 560025.5 688702.8 530191.6 727456.2
#> 6.854167       603271.1 542599.2 670727.2 512991.9 709438.2
#> 6.857143       605344.4 543093.3 674731.0 512774.4 714625.9
#> 6.860119       531877.0 476006.9 594304.7 448847.4 630265.6
#> 6.863095       493398.6 440507.5 552640.2 414844.0 586828.2
#> 6.866071       614901.6 547691.8 690359.1 515139.9 733983.1
#> 6.869048       644882.6 573068.9 725695.5 538349.3 772497.5
#> 6.872024       653127.5 579080.7 736642.5 543344.1 785092.6
#> 6.875000       665729.1 588941.2 752528.9 551945.2 802969.7
#> 6.877976       614736.0 542642.0 696408.2 507966.2 743947.8
#> 6.880952       536125.4 472234.7 608660.0 441555.5 650949.7
#> 6.883929       498143.3 437852.9 566735.5 408949.6 606790.6
#> 6.886905       614730.3 539207.1 700831.5 503059.4 751190.3
#> 6.889881       640258.7 560451.1 731430.8 522313.0 784838.1
#> 6.892857       641218.8 560161.4 734005.5 521486.3 788441.7
#> 6.895833       643834.0 561330.1 738464.2 522025.3 794065.3
#> 6.898810       626960.2 545549.6 720519.3 506824.3 775572.7
#> 6.901786       532129.4 462139.6 612718.9 428896.6 660209.8
#> 6.904762       507027.6 439501.6 584928.3 407476.0 630900.8
#> 6.907738       601120.5 520084.9 694782.3 481707.9 750134.6
#> 6.910714       625351.8 540046.9 724131.3 499705.9 782590.0
#> 6.913690       623415.3 537389.1 723212.6 496764.7 782355.5
#> 6.916667       628571.2 540854.0 730514.8 499488.9 791012.3
#> 6.919643       610116.9 524037.0 710336.4 483500.2 769891.3
#> 6.922619       546449.6 468523.7 637336.5 431876.8 691417.6
#> 6.925595       516003.4 441646.8 602878.8 406725.8 654641.3
#> 6.928571       653458.2 558328.7 764796.1 513711.6 831220.5
#> 6.931548       637732.1 543961.5 747667.4 500039.9 813339.6
#> 6.934524       610168.6 519571.6 716563.0 477191.9 780201.2
#> 6.937500       644627.5 547996.3 758298.3 502852.6 826374.7
#> 6.940476       628658.7 533536.8 740739.4 489155.2 807947.6
#> 6.943452       542535.9 459690.8 640311.3 421086.3 699014.0
#> 6.946429       516989.3 437334.5 611152.1 400263.3 667755.3
#> 6.949405       642718.3 542818.3 761003.8 496382.9 832193.9
#> 6.952381       679177.3 572697.5 805454.7 523264.6 881546.1
#> 6.955357       683438.2 575381.5 811787.8 525278.0 889220.1
#> 6.958333       693861.4 583244.0 825458.4 532015.2 904943.4
#> 6.961310       646019.1 542187.9 769734.4 494159.6 844546.2
#> 6.964286       567964.9 475947.2 677772.9 433434.1 744251.9
#> 6.967262       531948.7 445087.7 635761.1 405004.4 698682.4
#> 6.970238       653849.1 546257.6 782631.9 496666.0 860776.8
#> 6.973214       661976.5 552220.1 793547.6 501689.4 873474.7
#> 6.976190       638820.4 532112.3 766927.2 483041.6 844837.1
#> 6.979167       658343.3 547566.9 791530.6 496683.4 872620.1
#> 6.982143       646816.7 537194.0 778809.5 486897.6 859260.3
#> 6.985119       549422.1 455644.7 662500.1 412666.6 731497.6
#> 6.988095       427037.7 353640.1 515669.0 320039.6 569808.4
#> 6.991071       613684.7 507481.5 742113.4 458917.0 820647.0
#> 6.994048       615737.8 508458.1 745652.4 459455.2 825179.5
#> 6.997024       633905.5 522724.4 768734.3 471994.9 851357.0
#> 7.000000       634144.2 522191.3 770098.7 471165.0 853499.0
#> 7.002976       617189.3 507525.3 750549.1 457596.0 832443.1
#> 7.005952       566233.6 464982.7 689532.0 418933.2 765326.0
#> 7.008929       537562.6 440835.3 655513.7 396889.7 728095.4
#> 7.011905       674141.7 552088.4 823178.1 496695.1 914982.0
#> 7.014881       645058.6 527558.6 788728.7 474287.7 877317.0
#> 7.017857       659207.7 538408.4 807110.0 483698.7 898399.9
#> 7.020833       647520.6 528159.4 793856.8 474156.8 884270.6
#> 7.023810       650740.5 530084.2 798860.2 475551.7 890467.2
#> 7.026786       571071.8 464576.2 701979.4 416493.1 783021.3
#> 7.029762       540042.5 438760.1 664704.7 393077.1 741956.0
#> 7.032738       671764.1 545070.2 827906.2 487983.0 924759.7
#> 7.035714       704807.7 571144.8 869751.3 510977.7 972163.6
#> 7.038690       708362.2 573289.8 875258.8 512548.9 978983.6
#> 7.041667       712057.1 575546.5 880946.0 514219.5 986009.5
#> 7.044643       666541.4 538074.8 825679.7 480418.5 924771.8
#> 7.047619       593256.3 478311.8 735823.5 426774.7 824681.2
#> 7.050595       557852.9 449205.3 692778.8 400538.8 776953.1
#> 7.053571       683881.1 550003.2 850346.5 490093.5 954294.2
#> 7.056548       688435.7 552981.5 857069.8 492424.7 962469.6
#> 7.059524       671598.9 538794.0 837138.1 479478.4 940699.4
#> 7.062500       626934.0 502346.4 782420.9 446753.7 879782.9
#> 7.065476       561144.8 449084.3 701168.0 399128.8 788927.2
austria_arima_forecast
#>          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
#> 6.818452       521035.5 486949.2 557507.8 469817.2 577837.5
#> 6.821429       485338.6 450401.5 522985.7 432936.7 544083.0
#> 6.824405       561668.9 520222.7 606417.1 499535.1 631531.0
#> 6.827381       612925.9 566453.8 663210.5 543296.7 691478.7
#> 6.830357       610775.6 563009.8 662593.8 539255.4 691781.4
#> 6.833333       615167.4 565610.2 669066.6 541013.4 699485.3
#> 6.836310       592246.8 543208.9 645711.6 518915.4 675941.1
#> 6.839286       531240.4 486105.2 580566.5 463785.7 608506.0
#> 6.842262       499357.6 455881.0 546980.5 434419.8 574002.5
#> 6.845238       626133.8 570337.0 687389.3 542841.8 722205.9
#> 6.848214       597444.5 543012.0 657333.5 516234.3 691430.1
#> 6.851190       621464.9 563634.2 685229.3 535231.8 721591.3
#> 6.854167       603683.5 546360.1 667021.3 518252.3 703197.6
#> 6.857143       605758.2 547112.5 670690.2 518401.8 707835.1
#> 6.860119       532240.5 479745.1 590480.2 454085.4 623847.5
#> 6.863095       493735.9 444159.8 548845.4 419963.9 580466.8
#> 6.866071       615321.9 552464.9 685330.5 521833.0 725559.9
#> 6.869048       645323.4 578298.8 720116.1 545683.9 763156.7
#> 6.872024       653573.9 584596.7 730689.8 551080.0 775130.4
#> 6.875000       666184.2 594779.7 746160.9 560132.8 792314.6
#> 6.877976       615156.2 548226.7 690256.8 515796.5 733655.9
#> 6.880952       536491.8 477268.8 603063.8 448612.2 641586.5
#> 6.883929       498483.8 442677.8 561325.0 415711.2 597737.3
#> 6.886905       615150.5 545338.3 693899.9 511648.7 739589.8
#> 6.889881       640696.3 567016.1 723950.8 531506.8 772317.1
#> 6.892857       641657.1 566911.1 726258.2 530934.9 775469.5
#> 6.895833       644274.1 568278.5 730432.5 531747.7 780612.8
#> 6.898810       627388.7 552478.4 712456.2 516514.9 762062.5
#> 6.901786       532493.1 468155.0 605673.2 437305.7 648399.9
#> 6.904762       507374.2 445358.6 578025.3 415659.6 619325.4
#> 6.907738       601531.4 527174.0 686376.8 491608.0 736033.6
#> 6.910714       625779.3 547569.4 715159.9 510205.8 767532.8
#> 6.913690       623841.4 545032.5 714045.7 507427.5 766963.0
#> 6.916667       629000.9 548702.8 721050.0 510432.4 775111.8
#> 6.919643       610533.9 531790.7 700936.7 494305.1 754092.3
#> 6.922619       546823.2 475587.0 628729.5 441714.2 676943.6
#> 6.925595       516356.1 448426.6 594575.9 416162.9 640671.3
#> 6.928571       653904.9 567051.1 754061.7 525845.8 813150.1
#> 6.931548       638168.1 552604.9 736979.4 512057.3 795337.8
#> 6.934524       610585.7 527964.4 706136.5 488854.1 762630.2
#> 6.937500       645068.2 556990.7 747073.4 515343.4 807448.0
#> 6.940476       629088.4 542430.7 729590.4 501499.2 789138.3
#> 6.943452       542906.8 467470.1 630516.9 431876.9 682480.9
#> 6.946429       517342.7 444844.6 601656.0 410674.5 651716.7
#> 6.949405       643157.7 552273.8 748997.6 509483.2 811904.6
#> 6.952381       679641.6 582812.9 792557.4 537271.1 859738.7
#> 6.955357       683905.4 585682.9 798600.3 539533.5 866909.2
#> 6.958333       694335.7 593824.9 811859.0 546648.8 881922.8
#> 6.961310       646460.7 552151.5 756878.2 507931.4 822771.4
#> 6.964286       568353.1 484804.1 666300.6 445669.0 724809.8
#> 6.967262       532312.3 453472.8 624858.8 416580.6 680195.9
#> 6.970238       654296.0 556672.9 769039.3 511036.7 837715.4
#> 6.973214       662429.1 562873.3 779593.2 516379.7 849786.0
#> 6.976190       639257.0 542496.2 753276.4 497352.1 821650.4
#> 6.979167       658793.4 558373.0 777273.7 511567.2 848390.4
#> 6.982143       647258.8 547912.7 764618.1 501652.3 835128.1
#> 6.985119       549797.7 464834.7 650290.3 425309.7 710723.3
#> 6.988095       427329.6 360848.4 506059.1 329950.6 553448.4
#> 6.991071       614104.2 517933.3 728132.3 473279.1 796831.9
#> 6.994048       616158.7 519036.7 731454.0 473983.4 800980.6
#> 6.997024       634338.8 533708.7 753942.6 487071.5 826132.9
#> 7.000000       634577.7 533272.1 755128.3 486365.3 827955.6
#> 7.002976       617611.2 518398.6 735811.3 472503.1 807282.6
#> 7.005952       566620.6 475038.9 675858.2 432712.1 741969.0
#> 7.008929       537930.1 450457.8 642388.3 410067.0 705662.3
#> 7.011905       674602.6 564249.3 806538.1 513339.1 886526.4
#> 7.014881       645499.6 539283.5 772635.8 490325.7 849781.5
#> 7.017857       659658.4 550480.0 790490.4 500201.6 869947.5
#> 7.020833       647963.2 540103.8 777362.3 490476.8 856016.7
#> 7.023810       651185.3 542174.4 782114.2 492061.7 861766.6
#> 7.026786       571462.1 475261.3 687135.7 431076.0 757567.0
#> 7.029762       540411.6 448934.7 650528.3 406955.6 717632.8
#> 7.032738       672223.3 557812.8 810100.0 505354.8 894191.8
#> 7.035714       705289.5 584603.9 850889.5 529316.2 939765.9
#> 7.038690       708846.4 586906.0 856122.1 531091.1 946096.1
#> 7.041667       712543.9 589322.4 861529.8 532969.0 952623.6
#> 7.044643       666997.0 551052.3 807337.2 498071.6 893215.1
#> 7.047619       593661.9 489934.9 719349.5 442576.8 796323.7
#> 7.050595       558234.3 460202.2 677149.1 415481.5 750034.6
#> 7.053571       684348.6 563566.3 831016.6 508513.2 920984.9
#> 7.056548       688906.3 566716.6 837441.4 511067.8 928628.0
#> 7.059524       672057.9 552272.0 817825.0 497762.8 907383.7
#> 7.062500       627362.6 515000.9 764239.2 463911.9 848402.2
#> 7.065476       561528.4 460475.5 684757.7 414565.8 760589.0

2.10 Forecast and Actual Data Visualization

austria_train %>% 
  autoplot()+
  autolayer(austria_ets_forecast$mean, series = "forecast 1")+
  autolayer(austria_arima_forecast$mean, series = "forecast 2")+
  autolayer(austria_test, series = "test")

For see the goodnes of our model we will evaluate our model using RMSE as we want to penalizing large errors which find in our model

# model evaluation: root mean squared error (RMSE)

data.frame(ETS = RMSE(austria_ets_forecast$mean, austria_test), ARIMA = RMSE(austria_arima_forecast$mean, austria_test))

From the above result we can conclude that our forecast on power consumption in Austria as one of the country located on Western europe is successfully made and the best model with the lowest error is comming from Holtswinter Modelling with RMSE value at 40,673.94

For addition we also want to evaluate the model using MAE parameter for comparison

# model evaluation: Mean Absolute Error (RMSE)

data.frame(ETS = MAE(austria_ets_forecast$mean, austria_test), ARIMA = MAE(austria_arima_forecast$mean, austria_test))

from the above resultwe acknowldege that MAE value is lower than RMSE this could happen Since in the RMSE the errors are squared before they are averaged, the RMSE gives a relatively high weight to large errors.

2.11 Assumption Check

2.11.1 Normality

H0 : residuals are normally distributed H1 : residuals are not normally distributed

shapiro.test(austria_ets_forecast$residuals) # p-value < 0.05; reject H0; accept H1 
#> 
#>  Shapiro-Wilk normality test
#> 
#> data:  austria_ets_forecast$residuals
#> W = 0.76776, p-value < 2.2e-16
hist(austria_ets_forecast$residuals, breaks = 100)

2.11.2 Autocorrelation: Box.test - Ljng-Box

-H0 : No autocorrelation in the forecast errors -H1 : there is an autocorrelation in the forecast errors

Box.test(austria_ets_forecast$residuals, type = "Ljung-Box") 
#> 
#>  Box-Ljung test
#> 
#> data:  austria_ets_forecast$residuals
#> X-squared = 27.607, df = 1, p-value = 1.486e-07

Based on the assumption check, there is no autocorrelation on our forecast residuals (p-value > 0.05)

3 France Power Consumption Analysis Using Time Series

3.1 Read Data

# Power consumption in Austria
france <- read.csv("fr.csv")

head(france)
france <- france %>% 
  mutate(start = ymd_hms(start))

3.2 Data Aggregation

# Aggregate

france_agg <- france %>% 
           select(start,load)

3.3 Data Pre-procesing

3.3.1 Impute Missing Records

library(padr)

france_agg <- france_agg %>% 
  pad()
library(zoo)

france_agg <- france_agg %>% 
  mutate(load = na.fill(load, fill = "extend"))

3.3.2 Feature Engineering & Data Aggregation

daily_france <- france_agg %>% 
  mutate(year = year(start),
         month = month(start),
         day = day(start),
         date = paste0(year,"-",month,"-",day),
         date = ymd(date)) %>%
  select(-start, -year, -month, -day) %>% 
  group_by(date) %>% 
  summarise(load = sum(load))
daily_france
range(daily_austria$date)
#> [1] "2015-01-01" "2020-07-31"

3.4 Create Time Series Object and EDA

# Initial time series object

france_ts <- ts(data = daily_france$load,
                 start = range(daily_france$load)[[1]],
                 frequency = 7)
# decompose time series for austria into object

france_dc <- decompose (france_ts)

autoplot(france_dc)

Based on the plot, the trend still shows a pattern of ups and downs which indicates a multiseasonal time series object. Therefore, we should try reanalyze this data through multiseasonal time series using monthly.

daily_france$load %>% 
  msts(seasonal.periods = c(7,7*4)) %>% # multiseasonal ts (weekly, monthly)
  mstl() %>% # multiseasonal ts decomposition
  autoplot()

Based on the plot there is still pattern in trend, Therefore, we will add another seasonal frequency in yearly.

daily_france$load %>% 
  msts(seasonal.periods = c(7*4,7*4*12)) %>% # multiseasonal ts (monthly, yearly )
  mstl() %>% # multiseasonal ts decomposition
  autoplot()

From the plot it turns out that the trend is still showing up side down pattern, Therefore, we will try another seasonal frequency in every 2 years.

daily_france$load %>% 
  msts(seasonal.periods = c(7*4*12,7*4*12*2)) %>% # multiseasonal ts (monthly, yearly )
  mstl() %>% # multiseasonal ts decomposition
  autoplot()

The above graphic is showing the best decomposition among other trail. Therefore, we will use this ts object for our modelling.

# assign final ts object

## France
france_msts <- daily_france$load %>% 
  msts(seasonal.periods = c(7*4*12,7*4*12*2))

3.5 check for stationary

adf.test(france_msts)
#> 
#>  Augmented Dickey-Fuller Test
#> 
#> data:  france_msts
#> Dickey-Fuller = -2.6868, Lag order = 12, p-value = 0.2876
#> alternative hypothesis: stationary

From the above test result we see that the p-value is still greater than alpha this will give us notice on our modelling procedure

3.6 Cross Validation

The cross-validation scheme for time series should not be sampled randomly, but splitted sequentially.

france_train <- france_msts %>% head(length(france_msts) - 7*4*3)

france_test <- france_msts %>% tail(7*4*3)

3.7 Model Building

# ets Holt-Winters

france_ets <- stlm(france_train, method = "ets", lambda = 0)
# ARIMA

france_arima <- auto.arima(france_train)

3.8 Forecast & Evaluation

# forecast power Austria
france_ets_forecast <- forecast(france_ets, h = 7*4*3)
france_arima_forecast <- forecast(france_arima, h = 7*4*3)

france_ets_forecast
#>          Point Forecast    Lo 80     Hi 80    Lo 95     Hi 95
#> 3.909226       884568.9 852804.8  917516.1 836454.2  935451.2
#> 3.910714       833306.6 791307.7  877534.7 769938.5  901890.1
#> 3.912202       988832.7 928145.8 1053487.8 897542.5 1089408.2
#> 3.913690      1013860.7 942359.5 1090787.1 906573.4 1133844.8
#> 3.915179      1004970.7 926068.1 1090595.9 886839.0 1138838.0
#> 3.916667      1007513.8 921194.6 1101921.5 878535.2 1155428.0
#> 3.918155      1001728.7 909355.7 1103485.0 863956.2 1161471.4
#> 3.919643       876546.0 790419.1  972057.5 748306.8 1026761.8
#> 3.921131       833666.1 747051.1  930323.6 704904.4  985948.2
#> 3.922619       984308.2 876823.6 1104968.7 824760.7 1174719.7
#> 3.924107      1002764.7 888237.5 1132058.8 833004.4 1207121.0
#> 3.925595      1003594.2 884191.2 1139121.6 826846.0 1218124.4
#> 3.927083       998794.3 875422.8 1139552.2 816407.8 1221926.0
#> 3.928571       975075.7 850391.1 1118041.6 790977.1 1202023.0
#> 3.930060       853827.0 741079.5  983728.0 687552.6 1060312.4
#> 3.931548       810587.1 700289.3  938257.1 648113.2 1013791.1
#> 3.933036       972122.9 836072.7 1130312.0 771938.2 1224221.0
#> 3.934524      1000818.9 856998.6 1168775.0 789430.2 1268812.1
#> 3.936012      1007580.1 859128.1 1181683.5 789612.9 1285715.6
#> 3.937500      1014581.3 861523.2 1194831.7 790080.5 1302873.9
#> 3.938988       996014.3 842348.7 1177712.5 770846.3 1286954.9
#> 3.940476       865818.2 729357.5 1027810.2 666054.6 1125495.0
#> 3.941964       817866.0 686312.5  974636.0 625468.0 1069447.0
#> 3.943452       968092.0 809316.4 1158017.1 736095.9 1273206.6
#> 3.944940       993140.7 827195.7 1192376.3 750887.9 1313549.7
#> 3.946429       990760.7 822230.8 1193833.6 744951.8 1317678.2
#> 3.947917       990172.4 818829.1 1197369.9 740476.3 1324068.5
#> 3.949405       985895.8 812455.0 1196362.4 733357.3 1325398.5
#> 3.950893       884400.1 726322.8 1076881.4 654423.0 1195195.6
#> 3.952381       834320.6 682891.8 1019328.2 614195.9 1133336.9
#> 3.953869       967111.5 788964.9 1185483.2 708355.9 1320387.8
#> 3.955357       976887.9 794348.5 1201374.4 711960.7 1340396.9
#> 3.956845       966383.5 783290.8 1192273.8 700859.0 1332503.6
#> 3.958333       958979.8 774838.3 1186882.8 692137.6 1328698.5
#> 3.959821       954963.4 769195.0 1185596.7 685965.4 1329447.6
#> 3.961310       869619.2 698306.6 1082959.1 621736.6 1216331.0
#> 3.962798       824252.9 659877.4 1029574.3 586580.7 1158225.7
#> 3.964286       971421.0 775378.2 1217030.3 688163.6 1371271.0
#> 3.965774       989457.7 787451.1 1243285.4 697789.3 1403040.3
#> 3.967262       965093.7 765830.2 1216204.2 677585.9 1374594.6
#> 3.968750      1017133.5 804809.8 1285472.2 710991.9 1455094.9
#> 3.970238      1000963.0 789770.2 1268631.0 696658.0 1438190.6
#> 3.971726       893983.5 703386.8 1136226.2 619538.6 1290002.9
#> 3.973214       850489.5 667313.3 1083947.3 586903.3 1232455.9
#> 3.974702       992361.5 776498.1 1268234.0 681941.4 1444084.9
#> 3.976190      1019776.4 795789.7 1306807.5 697881.8 1490143.5
#> 3.977679      1043435.4 812071.9 1340715.6 711150.7 1530980.0
#> 3.979167      1047727.8 813252.3 1349806.9 711184.9 1543527.7
#> 3.980655      1027651.5 795577.6 1327422.7 694762.3 1520041.8
#> 3.982143       922605.4 712400.3 1194835.0 621269.9 1370098.2
#> 3.983631       872821.5 672227.3 1133273.4 585438.0 1301277.6
#> 3.985119      1011402.2 776977.0 1316557.0 675751.8 1513772.5
#> 3.986607      1030575.3 789710.9 1344904.2 685909.9 1548433.1
#> 3.988095      1034157.2 790477.3 1352956.3 685667.6 1559766.2
#> 3.989583      1037876.7 791358.0 1361189.2 685532.2 1571316.3
#> 3.991071      1031132.6 784288.7 1355667.3 678526.2 1566976.4
#> 3.992560       925000.8 701854.6 1219093.6 606427.1 1410930.5
#> 3.994048       877367.1 664108.8 1159106.7 573081.5 1343217.3
#> 3.995536       998116.7 753704.5 1321787.3 649574.1 1533677.3
#> 3.997024       993452.7 748406.6 1318732.8 644199.3 1532054.3
#> 3.998512      1066606.0 801629.3 1419170.2 689153.3 1650791.5
#> 4.000000      1156414.2 867102.6 1542255.7 744520.6 1796181.1
#> 4.001488      1163571.4 870453.8 1555393.9 746483.6 1813701.5
#> 4.002976      1036590.4 773683.6 1388835.9 662690.1 1621451.0
#> 4.004464       998561.0 743604.8 1340932.9 636159.3 1567412.6
#> 4.005952      1200433.6 891917.3 1615666.3 762129.8 1890807.5
#> 4.007440      1244843.7 922842.5 1679198.6 787619.5 1967492.8
#> 4.008929      1233856.2 912663.9 1668085.3 778015.3 1956775.3
#> 4.010417      1191651.7 879500.9 1614590.6 748868.8 1896238.7
#> 4.011905      1125621.9 828947.4 1528474.0 705005.1 1797185.1
#> 4.013393      1047911.0 770039.9 1426052.8 654150.7 1678691.8
#> 4.014881      1004233.0 736349.9 1369571.5 624815.5 1614050.7
#> 4.016369      1180699.1 863886.0 1613697.0 732201.0 1903917.4
#> 4.017857      1189344.3 868357.7 1628982.9 735160.6 1924123.5
#> 4.019345      1182148.3 861277.5 1622560.3 728349.3 1918687.4
#> 4.020833      1173343.3 853065.5 1613867.1 720601.6 1910534.6
#> 4.022321      1170218.7 849017.3 1612937.6 716388.8 1911548.3
#> 4.023810      1075538.8 778706.2 1485520.2 656339.4 1762478.2
#> 4.025298      1031530.5 745303.9 1427679.5 627500.1 1695705.0
#> 4.026786      1185035.3 854460.7 1643502.9 718622.9 1954166.2
#> 4.028274      1226519.6 882572.4 1704506.6 741465.3 2028888.5
#> 4.029762      1236318.0 887823.2 1721606.6 745077.4 2051440.9
#> 4.031250      1237113.9 886608.2 1726186.0 743265.4 2059090.6
#> 4.032738      1247150.4 892014.7 1743675.7 747006.1 2082157.4
france_arima_forecast
#>          Point Forecast    Lo 80   Hi 80    Lo 95   Hi 95
#> 3.909226       912691.9 806152.0 1019232 749753.2 1075631
#> 3.910714       970302.6 812621.4 1127984 729150.0 1211455
#> 3.912202       992844.9 821150.7 1164539 730261.3 1255428
#> 3.913690      1008768.8 829159.1 1188378 734079.4 1283458
#> 3.915179      1009946.9 825968.4 1193925 728576.0 1291318
#> 3.916667       997149.8 808498.4 1185801 708632.4 1285667
#> 3.918155       999151.6 801296.0 1197007 696557.5 1301746
#> 3.919643      1011085.3 803294.4 1218876 693296.5 1328874
#> 3.921131      1021947.9 806327.6 1237568 692185.1 1351711
#> 3.922619      1031564.1 809717.3 1253411 692278.8 1370849
#> 3.924107      1036815.8 810020.4 1263611 689962.2 1383669
#> 3.925595      1039140.5 807695.3 1270586 685175.6 1393105
#> 3.927083      1043194.2 806762.3 1279626 681602.9 1404785
#> 3.928571      1049015.3 807588.1 1290443 679784.3 1418246
#> 3.930060      1055389.4 809297.4 1301481 679024.2 1431755
#> 3.931548      1061619.6 811300.4 1311939 678789.4 1444450
#> 3.933036      1066854.2 812727.8 1320981 678201.4 1455507
#> 3.934524      1071335.3 813650.5 1329020 677240.4 1465430
#> 3.936012      1075835.1 814715.4 1336955 676486.9 1475183
#> 3.937500      1080560.2 816132.1 1344988 676152.3 1484968
#> 3.938988      1085429.1 817855.1 1353003 676209.9 1494648
#> 3.940476      1090253.4 819722.0 1360785 676511.3 1503995
#> 3.941964      1094827.5 821526.6 1368128 676849.9 1512805
#> 3.943452      1099159.5 823246.5 1375072 677187.0 1521132
#> 3.944940      1103373.5 824976.9 1381770 677602.7 1529144
#> 3.946429      1107542.8 826779.3 1388306 678152.1 1536934
#> 3.947917      1111682.2 828666.3 1394698 678846.7 1544518
#> 3.949405      1115758.0 830604.8 1400911 679653.8 1551862
#> 3.950893      1119726.2 832547.6 1406905 680524.4 1558928
#> 3.952381      1123578.7 834478.3 1412679 681437.9 1565719
#> 3.953869      1127334.1 836406.7 1418261 682399.0 1572269
#> 3.955357      1131011.9 838345.3 1423679 683416.9 1578607
#> 3.956845      1134622.0 840299.4 1428945 684494.4 1584750
#> 3.958333      1138161.4 842262.8 1434060 685623.5 1590699
#> 3.959821      1141622.6 844224.4 1439021 686791.4 1596454
#> 3.961310      1145002.9 846177.6 1443828 687989.0 1602017
#> 3.962798      1148305.5 848121.2 1448490 689213.2 1607398
#> 3.964286      1151535.8 850056.6 1453015 690463.2 1612608
#> 3.965774      1154697.7 851984.5 1457411 691737.8 1617658
#> 3.967262      1157792.7 853903.2 1461682 693033.9 1622552
#> 3.968750      1160820.6 855809.9 1465831 694347.1 1627294
#> 3.970238      1163781.5 857702.1 1469861 695673.4 1631890
#> 3.971726      1166677.0 859578.4 1473775 697010.3 1636344
#> 3.973214      1169508.9 861438.3 1477579 698355.6 1640662
#> 3.974702      1172279.3 863281.5 1481277 699708.0 1644851
#> 3.976190      1174989.8 865107.3 1484872 701065.5 1648914
#> 3.977679      1177641.3 866914.7 1488368 702426.0 1652857
#> 3.979167      1180234.9 868702.7 1491767 703787.6 1656682
#> 3.980655      1182771.7 870470.7 1495073 705148.6 1660395
#> 3.982143      1185253.0 872218.2 1498288 706507.6 1663998
#> 3.983631      1187680.2 873944.9 1501416 707863.4 1667497
#> 3.985119      1190054.6 875650.3 1504459 709214.7 1670894
#> 3.986607      1192377.2 877334.2 1507420 710560.5 1674194
#> 3.988095      1194649.1 878996.2 1510302 711899.7 1677399
#> 3.989583      1196871.5 880636.1 1513107 713231.2 1680512
#> 3.991071      1199045.3 882253.6 1515837 714554.1 1683536
#> 3.992560      1201171.7 883848.5 1518495 715867.8 1686476
#> 3.994048      1203251.7 885420.9 1521083 717171.4 1689332
#> 3.995536      1205286.4 886970.5 1523602 718464.3 1692108
#> 3.997024      1207276.6 888497.4 1526056 719745.9 1694807
#> 3.998512      1209223.5 890001.5 1528445 721015.6 1697431
#> 4.000000      1211127.9 891482.8 1530773 722272.9 1699983
#> 4.001488      1212990.7 892941.3 1533040 723517.5 1702464
#> 4.002976      1214812.8 894377.2 1535249 724748.8 1704877
#> 4.004464      1216595.3 895790.3 1537400 725966.5 1707224
#> 4.005952      1218338.8 897181.0 1539497 727170.3 1709507
#> 4.007440      1220044.3 898549.1 1541539 728359.9 1711729
#> 4.008929      1221712.6 899895.0 1543530 729535.0 1713890
#> 4.010417      1223344.5 901218.7 1545470 730695.6 1715993
#> 4.011905      1224940.8 902520.3 1547361 731841.2 1718040
#> 4.013393      1226502.3 903800.1 1549204 732971.9 1720033
#> 4.014881      1228029.7 905058.2 1551001 734087.5 1721972
#> 4.016369      1229523.7 906294.9 1552753 735187.8 1723860
#> 4.017857      1230985.2 907510.2 1554460 736272.9 1725698
#> 4.019345      1232414.8 908704.5 1556125 737342.5 1727487
#> 4.020833      1233813.2 909877.8 1557749 738396.8 1729230
#> 4.022321      1235181.1 911030.6 1559332 739435.6 1730927
#> 4.023810      1236519.2 912162.9 1560876 740459.0 1732579
#> 4.025298      1237828.1 913275.0 1562381 741466.9 1734189
#> 4.026786      1239108.4 914367.1 1563850 742459.5 1735757
#> 4.028274      1240360.8 915439.6 1565282 743436.7 1737285
#> 4.029762      1241585.8 916492.6 1566679 744398.6 1738773
#> 4.031250      1242784.1 917526.3 1568042 745345.2 1740223
#> 4.032738      1243956.3 918541.1 1569372 746276.7 1741636

3.9 Forecast and Actual Data Visualization

france_train %>% 
  autoplot()+
  autolayer(france_ets_forecast$mean, series = "forecast 1")+
  autolayer(france_arima_forecast$mean, series = "forecast 2")+
  autolayer(france_test, series = "test")

# model evaluation: root mean squared error (RMSE)

data.frame(ETS = RMSE(france_ets_forecast$mean, france_test), ARIMA = RMSE(france_arima_forecast$mean, france_test))

From the above result we can conclude that our forecast on power consumption in france as one of the country located on Western europe is successfully made and the best model with the lowest error is comming from Holtswinter Modelling with RMSE value at 80,182.26 with significant different compare to Arima Modeling.

3.10 Assumption Check

3.10.1 Normality

-H0 : residuals are normally distributed -H1 : residuals are not normally distributed

shapiro.test(france_ets_forecast$residuals) # p-value < 0.05; reject H0; accept H1 
#> 
#>  Shapiro-Wilk normality test
#> 
#> data:  france_ets_forecast$residuals
#> W = 0.96819, p-value < 2.2e-16
hist(france_ets_forecast$residuals, breaks = 100)

3.10.2 Autocorrelation: Box.test - Ljng-Box

-H0 : No autocorrelation in the forecast errors -H1 : there is an autocorrelation in the forecast errors

Box.test(france_ets_forecast$residuals, type = "Ljung-Box") 
#> 
#>  Box-Ljung test
#> 
#> data:  france_ets_forecast$residuals
#> X-squared = 0.07763, df = 1, p-value = 0.7805

Based on the assumption check, there is no autocorrelation on our forecast residuals (p-value > 0.05)

4 Conclusion

From our modeling result based on two country (Austria & France), we see that the error value of is high.

In our case the errors might occurs from the anomaly event that occurs on the country which need more amount of energy than usual.