knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.height = 5, fig.width = 7 )
library(echos) library(tidyverse) library(tsibble) library(fable)
In this example, we will use the m4_data
. The dataset is a monthly tsibble
, which is filtered to include only the time series "M21655"
and "M2717"
. The resulting object train_frame
contains the training data and is visualized below.
train_frame <- m4_data %>% filter(series %in% c("M21655", "M2717")) train_frame p <- ggplot() p <- p + geom_line( data = train_frame, aes( x = index, y = value), linewidth = 0.5 ) p <- p + facet_wrap( vars(series), ncol = 1, scales = "free") p
The function ESN()
is used in combination with model()
from the fabletools
package to train an Echo State Network for the variable value
. The trained models are stored as a mable
(i.e., model table). Additionally, an ARIMA()
model is trained as benchmark.
mable_frame <- train_frame %>% model( "ESN" = ESN(value), "ARIMA" = ARIMA(value) ) mable_frame
Forecasts are generated via the function forecast()
, where the forecast horizon is set to h = 18
(i.e., 18-month ahead forecasts). The forecasts are stored as fable
(i.e., forecast table) and visualized along the historic training data.
fable_frame <- mable_frame %>% forecast(h = 18) fable_frame fable_frame %>% autoplot(train_frame, level = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.