-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
97 lines (70 loc) · 3.28 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
dev = "svg",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# echos <img src="man/figures/logo.png" align="right" height="139" alt="" />
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![Licence](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
[![Codecov test coverage](https://codecov.io/gh/ahaeusser/echos/branch/master/graph/badge.svg)](https://app.codecov.io/gh/ahaeusser/echos?branch=master)
[![R-CMD-check](https://github.com/ahaeusser/echos/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ahaeusser/echos/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The `echos` package provides a comprehensive set of **functions and methods** for modeling and forecasting univariate time series using **Echo State Networks (ESNs)**. It offers two alternative approaches:
* **Base R interface:** Functions for modeling and forecasting time series using `numeric` vectors, allowing for straightforward integration with existing R workflows.
* **Tidy interface:** A seamless integration with the [`fable`](https://github.com/tidyverts/fable) framework based on [`tsibble`](https://github.com/tidyverts/tsibble), enabling tidy time series forecasting and model evaluation. This interface leverages the [`fabletools`](https://github.com/tidyverts/fabletools) package, providing a consistent and streamlined workflow for model development, evaluation, and visualization.
The package features a **lightweight implementation** that enables **fast and fully automatic** model training and forecasting using ESNs. You can quickly and easily build accurate ESN models without requiring extensive hyperparameter tuning or manual configuration.
## Installation
You can install the **stable** version from [CRAN](https://cran.r-project.org/package=echos):
``` r
install.packages("echos")
```
You can install the **development** version from [GitHub](https://github.com/):
``` r
# install.packages("devtools")
devtools::install_github("ahaeusser/echos")
```
## Base R
```{r base, message = FALSE, warning = FALSE, fig.alt = "Plot forecast and test data"}
library(echos)
# Forecast horizon
n_ahead <- 12 # forecast horizon
# Number of observations
n_obs <- length(AirPassengers)
# Number of observations for training
n_train <- n_obs - n_ahead
# Prepare train and test data
xtrain <- AirPassengers[(1:n_train)]
xtest <- AirPassengers[((n_train+1):n_obs)]
# Train and forecast ESN model
xmodel <- train_esn(y = xtrain)
xfcst <- forecast_esn(xmodel, n_ahead = n_ahead)
# Plot result
plot(xfcst, test = xtest)
```
## Tidy R
```{r tidy, message = FALSE, warning = FALSE, fig.alt = "Plot forecast and train data"}
library(echos)
library(tidyverse)
library(tsibble)
library(fable)
# Prepare train data
train_frame <- m4_data %>%
filter(series %in% c("M21655", "M2717"))
# Train and forecast ESN model
train_frame %>%
model(
"ESN" = ESN(value),
"ARIMA" = ARIMA(value)
) %>%
forecast(h = 18) %>%
autoplot(train_frame, level = NULL)
```