knitr::opts_chunk$set(warning = F,message = F,fig.width = 8,fig.height = 5)
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(lubridate))
library(autoTS)## Loading required package: prophet
## Loading required package: Rcpp
## Loading required package: rlang
The autoTS package provides a high level interface for univariate time series predictions. It implements many algorithms, most of them provided by the forecast package. The main goals of the package are :
The package is designed to work on one time series at a time. Parallel calculations can be put on top of it (see example below). The user has to provide 2 simple vectors :
lubridate package can parse them)This package implements each algorithm with a unique parametrization, meaning that the user cannot tweak the algorithms (eg modify SARIMA specfic parameters).
For this example, we will use the GDP quarterly data of the european countries provided by eurostat. The database can be downloaded from this page and then chose “GDP and main components (output, expenditure and income) (namq_10_gdp)” and then adjust the time dimension to select all available data and download as a csv file with the correct formatting (1 234.56). The csv is in the “Data” folder of this notebook.
## 'data.frame': 93456 obs. of 7 variables:
## $ TIME : Factor w/ 177 levels "1975Q1","1975Q2",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ GEO : Factor w/ 44 levels "Albania","Austria",..: 15 15 15 15 15 15 15 15 15 15 ...
## $ UNIT : Factor w/ 3 levels "Chain linked volumes (2010), million euro",..: 2 2 2 2 3 3 3 3 1 1 ...
## $ S_ADJ : Factor w/ 4 levels "Calendar adjusted data, not seasonally adjusted data",..: 4 2 1 3 4 2 1 3 4 2 ...
## $ NA_ITEM : Factor w/ 1 level "Gross domestic product at market prices": 1 1 1 1 1 1 1 1 1 1 ...
## $ Value : Factor w/ 19709 levels ":","1 008.3",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Flag.and.Footnotes: Factor w/ 5 levels "","b","c","e",..: 1 1 1 1 1 1 1 1 1 1 ...
## TIME GEO
## 1 1975Q1 European Union - 27 countries (from 2019)
## 2 1975Q1 European Union - 27 countries (from 2019)
## 3 1975Q1 European Union - 27 countries (from 2019)
## 4 1975Q1 European Union - 27 countries (from 2019)
## 5 1975Q1 European Union - 27 countries (from 2019)
## 6 1975Q1 European Union - 27 countries (from 2019)
## UNIT
## 1 Chain linked volumes, index 2010=100
## 2 Chain linked volumes, index 2010=100
## 3 Chain linked volumes, index 2010=100
## 4 Chain linked volumes, index 2010=100
## 5 Current prices, million euro
## 6 Current prices, million euro
## S_ADJ
## 1 Unadjusted data (i.e. neither seasonally adjusted nor calendar adjusted data)
## 2 Seasonally adjusted data, not calendar adjusted data
## 3 Calendar adjusted data, not seasonally adjusted data
## 4 Seasonally and calendar adjusted data
## 5 Unadjusted data (i.e. neither seasonally adjusted nor calendar adjusted data)
## 6 Seasonally adjusted data, not calendar adjusted data
## NA_ITEM Value Flag.and.Footnotes
## 1 Gross domestic product at market prices :
## 2 Gross domestic product at market prices :
## 3 Gross domestic product at market prices :
## 4 Gross domestic product at market prices :
## 5 Gross domestic product at market prices :
## 6 Gross domestic product at market prices :
First, we have to clean the data (not too ugly though). First thing is to convert the TIME column into a well known date format that lubridate can handle. In this example, the yq function can parse the date without modification of the column. Then, we have to remove the blank in the values that separates thousands… Finally, we only keep data since 2000 and the unadjusted series in current prices.
After that, we should get one time series per country
dat <- mutate(dat,dates=yq(as.character(TIME)),
values = as.numeric(stringr::str_remove(Value," "))) %>%
filter(year(dates)>=2000 &
S_ADJ=="Unadjusted data (i.e. neither seasonally adjusted nor calendar adjusted data)" &
UNIT == "Current prices, million euro")
filter(dat,GEO %in% c("France","Austria")) %>%
ggplot(aes(dates,values,color=GEO)) + geom_line() + theme_light() +
labs(title="GDP of (completely) random countries")Now we’re good to go !
Let’s see how to use the package on one time series :
ex1 <- filter(dat,GEO=="France")
preparedTS <- prepare.ts(ex1$dates,ex1$values,"quarter")
## What is in this new object ?
str(preparedTS)## List of 4
## $ obj.ts : Time-Series [1:77] from 2000 to 2019: 363007 369185 362905 383489 380714 ...
## $ obj.df :'data.frame': 77 obs. of 2 variables:
## ..$ dates: Date[1:77], format: "2000-01-01" "2000-04-01" ...
## ..$ val : num [1:77] 363007 369185 362905 383489 380714 ...
## $ freq.num : num 4
## $ freq.alpha: chr "quarter"
## What is the best model for prediction ?
best.algo <- getBestModel(ex1$dates,ex1$values,"quarter",bagged = T,graph = F)
names(best.algo)## [1] "best" "graph.train" "res.train"
## [1] "The best algorithm is my.prophet"
## Build the predictions
final.pred <- my.predictions(preparedTS,best.algo$best)
tail(final.pred,24)## # A tibble: 24 x 4
## dates type prophet actual.value
## <date> <chr> <dbl> <dbl>
## 1 2016-04-01 <NA> NA 560873
## 2 2016-07-01 <NA> NA 546383
## 3 2016-10-01 <NA> NA 572752
## 4 2017-01-01 <NA> NA 565221
## 5 2017-04-01 <NA> NA 573720
## 6 2017-07-01 <NA> NA 563671
## 7 2017-10-01 <NA> NA 592453
## 8 2018-01-01 <NA> NA 580884
## 9 2018-04-01 <NA> NA 586869
## 10 2018-07-01 <NA> NA 577904
## # ... with 14 more rows
ggplot(final.pred) + geom_line(aes(dates,actual.value),color="black") +
geom_line(aes(dates,prophet,linetype=type),color="red") +
theme_light() Not too bad, right ?
Let’s say we want to make a prediction for each country in the same time and be the fastest possible \(\rightarrow\) let’s combine the package’s functions with parallel computing. We have to reshape the data to get one column per country and then iterate over the columns of the data frame.
suppressPackageStartupMessages(library(tidyr))
dat.wide <- select(dat,GEO,dates,values) %>%
group_by(dates) %>%
spread(key = "GEO",value = "values")
head(dat.wide)## # A tibble: 6 x 45
## # Groups: dates [6]
## dates Albania Austria Belgium `Bosnia and Her~ Bulgaria Croatia Cyprus
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2000-01-01 NA 50422. 62261 NA 2941. 5266. 2547.
## 2 2000-04-01 NA 53180. 65046 NA 3252. 5811 2784.
## 3 2000-07-01 NA 53881. 62754 NA 4015. 6409. 2737.
## 4 2000-10-01 NA 56123. 68161 NA 4103. 6113 2738.
## 5 2001-01-01 NA 52911. 64318 NA 3284. 5777. 2688.
## 6 2001-04-01 NA 54994. 67537 NA 3669. 6616. 2946.
## # ... with 37 more variables: Czechia <dbl>, Denmark <dbl>, Estonia <dbl>,
## # `Euro area (12 countries)` <dbl>, `Euro area (19 countries)` <dbl>, `Euro
## # area (EA11-2000, EA12-2006, EA13-2007, EA15-2008, EA16-2010, EA17-2013,
## # EA18-2014, EA19)` <dbl>, `European Union - 15 countries (1995-2004)` <dbl>,
## # `European Union - 27 countries (from 2019)` <dbl>, `European Union - 28
## # countries` <dbl>, Finland <dbl>, France <dbl>, `Germany (until 1990 former
## # territory of the FRG)` <dbl>, Greece <dbl>, Hungary <dbl>, Iceland <dbl>,
## # Ireland <dbl>, Italy <dbl>, `Kosovo (under United Nations Security Council
## # Resolution 1244/99)` <dbl>, Latvia <dbl>, Lithuania <dbl>,
## # Luxembourg <dbl>, Malta <dbl>, Montenegro <dbl>, Netherlands <dbl>, `North
## # Macedonia` <dbl>, Norway <dbl>, Poland <dbl>, Portugal <dbl>,
## # Romania <dbl>, Serbia <dbl>, Slovakia <dbl>, Slovenia <dbl>, Spain <dbl>,
## # Sweden <dbl>, Switzerland <dbl>, Turkey <dbl>, `United Kingdom` <dbl>
library(doParallel)
pipeline <- function(dates,values)
{
bm <- getBestModel(dates,values,"quarter",graph = F)
pred <- prepare.ts(dates,values,"quarter") %>%
my.predictions(bm$best)
return(pred)
}
#doMC::registerDoMC(parallel::detectCores()-1) # parallel backend (for UNIX)
system.time({
res <- foreach(ii=2:ncol(dat.wide),.packages = c("dplyr","autoTS")) %dopar%
pipeline(dat.wide$dates,pull(dat.wide,ii))
})## user system elapsed
## 340.07 0.12 343.08
## List of 44
## $ Albania :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ stlm : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ Austria :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 50422 53180 53881 56123 52911 ...
## $ Belgium :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 62261 65046 62754 68161 64318 ...
## $ Bosnia and Herzegovina :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ stlm : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ Bulgaria :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 2941 3252 4015 4103 3284 ...
## $ Croatia :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ tbats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 5266 5811 6409 6113 5777 ...
## $ Cyprus :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 2547 2784 2737 2738 2688 ...
## $ Czechia :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 15027 16430 17229 18191 16677 ...
## $ Denmark :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 42567 44307 43892 47249 44143 ...
## $ Estonia :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 1391 1575 1543 1662 1570 ...
## $ Euro area (12 countries) :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ bats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ Euro area (19 countries) :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ bats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ Euro area (EA11-2000, EA12-2006, EA13-2007, EA15-2008, EA16-2010, EA17-2013, EA18-2014, EA19):Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ bats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ European Union - 15 countries (1995-2004) :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ bats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ European Union - 27 countries (from 2019) :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ bats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ European Union - 28 countries :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ bats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ Finland :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 31759 33836 34025 36641 34474 ...
## $ France :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 363007 369185 362905 383489 380714 ...
## $ Germany (until 1990 former territory of the FRG) :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 515500 523900 536120 540960 530610 ...
## $ Greece :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 33199 34676 37285 37751 35237 ...
## $ Hungary :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 11516 12630 13194 13955 12832 ...
## $ Iceland :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ bats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 2304 2442 2557 2447 2232 ...
## $ Ireland :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 25583 26751 27381 28666 29766 ...
## $ Italy :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 292517 309099 298655 338996 309967 ...
## $ Kosovo (under United Nations Security Council Resolution 1244/99) :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ stlm : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ Latvia :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ actual.value: num [1:89] 1848 2165 2238 2382 2005 ...
## ..$ bagged : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## $ Lithuania :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ stlm : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 2657 3124 3267 3505 2996 ...
## $ Luxembourg :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 5646 5730 5689 6015 5811 ...
## $ Malta :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 979 1110 1158 1152 1031 ...
## $ Montenegro :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ ets : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 0 0 0 0 0 ...
## $ Netherlands :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 109154 113124 110955 118774 118182 ...
## $ North Macedonia :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 901 1052 1033 1108 986 ...
## $ Norway :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ actual.value: num [1:89] 44900 43730 46652 50638 48355 ...
## ..$ bagged : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## $ Poland :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 41341 44210 46944 54163 47445 ...
## $ Portugal :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 30644 31923 32111 33788 31927 ...
## $ Romania :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ actual.value: num [1:89] 7901 9511 11197 11630 8530 ...
## ..$ bagged : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## $ Serbia :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ actual.value: num [1:89] 0 0 0 0 0 ...
## ..$ bagged : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## $ Slovakia :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ sarima : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 5100 5722 5764 5752 5343 ...
## $ Slovenia :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ tbats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 5147 5591 5504 5667 5407 ...
## $ Spain :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 153378 162400 158526 171946 166204 ...
## $ Sweden :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ stlm : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 67022 73563 68305 73399 66401 ...
## $ Switzerland :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ bats : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 70049 72725 74957 77476 76092 ...
## $ Turkey :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ stlm : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 59944 70803 82262 82981 60075 ...
## $ United Kingdom :Classes 'tbl_df', 'tbl' and 'data.frame': 89 obs. of 4 variables:
## ..$ dates : Date[1:89], format: "2000-01-01" "2000-04-01" ...
## ..$ type : chr [1:89] NA NA NA NA ...
## ..$ prophet : num [1:89] NA NA NA NA NA NA NA NA NA NA ...
## ..$ actual.value: num [1:89] 438090 440675 446918 462127 441157 ...
There is no best algorithm in general \(\Rightarrow\) depends on the data !
## .
## bagged bats ets prophet sarima stlm tbats
## 4 8 1 13 10 6 2
## Albania
## "stlm"
## Austria
## "prophet"
## Belgium
## "prophet"
## Bosnia and Herzegovina
## "stlm"
## Bulgaria
## "sarima"
## Croatia
## "tbats"
## Cyprus
## "sarima"
## Czechia
## "sarima"
## Denmark
## "prophet"
## Estonia
## "sarima"
## Euro area (12 countries)
## "bats"
## Euro area (19 countries)
## "bats"
## Euro area (EA11-2000, EA12-2006, EA13-2007, EA15-2008, EA16-2010, EA17-2013, EA18-2014, EA19)
## "bats"
## European Union - 15 countries (1995-2004)
## "bats"
## European Union - 27 countries (from 2019)
## "bats"
## European Union - 28 countries
## "bats"
## Finland
## "sarima"
## France
## "prophet"
## Germany (until 1990 former territory of the FRG)
## "prophet"
## Greece
## "prophet"
## Hungary
## "prophet"
## Iceland
## "bats"
## Ireland
## "sarima"
## Italy
## "prophet"
## Kosovo (under United Nations Security Council Resolution 1244/99)
## "stlm"
## Latvia
## "bagged"
## Lithuania
## "stlm"
## Luxembourg
## "sarima"
## Malta
## "prophet"
## Montenegro
## "ets"
## Netherlands
## "sarima"
## North Macedonia
## "sarima"
## Norway
## "bagged"
## Poland
## "prophet"
## Portugal
## "prophet"
## Romania
## "bagged"
## Serbia
## "bagged"
## Slovakia
## "sarima"
## Slovenia
## "tbats"
## Spain
## "prophet"
## Sweden
## "stlm"
## Switzerland
## "bats"
## Turkey
## "stlm"
## United Kingdom
## "prophet"