knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  warning = FALSE
)

gts vr as.character(packageVersion("gts"))

Lifecycle: experimental

The goal of gts is to speed up the functionality provided by fable.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("markfairbanks/gts")

Functions

gts has 3 core functions:

Examples

Starting with some example data:

library(gts)
library(fpp3)
library(tidyverse)

aus_df <- tsibbledata::aus_livestock %>%
  rename_all(janitor::make_clean_names) %>%
  filter(state == "Australian Capital Territory") %>%
  mutate(month = as_date(month))

head(aus_df)

You can then use this to prep your data and create models

aus_ts <- aus_df %>%
  ts_prep(key = c(animal, state), index = month, target = count) %>%
  mutate(mable = map(time_series, model,
                     ets = ETS(count)))

aus_ts

You can create forecasts from here, or get model accuracy.

aus_ts <- aus_ts %>%
  mutate(fable = map(mable, forecast, h = 1),
         accuracy = map(mable, accuracy))

aus_ts

You can unnest the fable as follows:

aus_ts %>%
  ts_unnest_fable(fable)

Running in parallel

pacman::p_load(furrr)

model_fn <- function(.data) {
  .data %>%
    mutate(mable = map(time_series, model,
                       ets = ETS(count)),
           fable = map(mable, forecast, h = 1),
           accuracy = map(mable, accuracy))
}

plan(multiprocess)

parallel_ts <- aus_df %>%
  ts_prep(key = c(animal, state), index = month, target = count) %>%
  ts_split(6) %>%
  future_map_dfr(model_fn)

future:::ClusterRegistry("stop")


mtfairbanks/gts documentation built on Feb. 12, 2020, 1:22 p.m.