-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
78 lines (58 loc) · 2.52 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# vctsfr
<!-- badges: start -->
<!-- badges: end -->
The goal of vctsfr is to display time series and, optionally, their future values and forecasts for those future values along with prediction intervals for the forecasts. vctsfr is especially useful when you want to visually compare the forecasts of several models on collections of time series. The package contains a web-based GUI to facilitate this comparison.
## Installation
The package can be intalled from CRAN with:
```{r, eval = FALSE}
install.packages("vctsfr")
```
For installing the development version of vctsfr from [GitHub](https://github.com/):
``` r
# install.packages("devtools")
devtools::install_github("franciscomartinezdelrio/vctsfr")
```
## Example
The best way of learning to use the package is to read its vignette. Here, we show some functions in action. The `plot_ts()` function is useful to display a time series and a forecast for its future values:
```{r example}
library(vctsfr)
library(forecast)
ets_fit <- ets(USAccDeaths)
ets_f <- forecast(ets_fit, h = 12)
plot_ts(USAccDeaths, prediction = ets_f$mean, method = "ets")
```
To compare several forecasts for a time series you can use the `plot_predictions()` function:
```{r example2}
library(vctsfr)
library(forecast)
timeS <- window(USAccDeaths, end = c(1977, 12)) # historical values
fut <- window(USAccDeaths, start = c(1978, 1)) # "future" values
ets_fit <- ets(timeS) # exponential smoothing fit
ets_f <- forecast(ets_fit, h = length(fut)) # exponential smoothing forecast
arima_fit <- auto.arima(timeS) # ARIMA fit
arima_f <- forecast(arima_fit, h = length(fut)) # ARIMA forecast
plot_predictions(timeS, future = fut,
predictions = list(ets = ets_f$mean, arima = arima_f$mean) )
```
It is also possible to create a collection of time series (holding optionally their future values, forecasts and prediction intervals for the forecasts) and display them:
```{r}
# A collection of two time series
collection <- list(ts_info(USAccDeaths), ts_info(UKDriverDeaths))
plot_collection(collection, number = 2)
```
However, the best way of navigating and displaying the information in a collection of time series is through the web-based GUI:
```{r, eval=FALSE}
GUI_collection(collection)
```