knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) options(width = 100)
feasts provides a collection of tools for the analysis of time series data. The package name is an acronym comprising of its key features: Feature Extraction And Statistics for Time Series.
The package works with tidy temporal data provided by the tsibble package to produce time series features, decompositions, statistical summaries and convenient visualisations. These features are useful in understanding the behaviour of time series data, and closely integrates with the tidy forecasting workflow used in the fable package.
You could install the stable version from CRAN:
install.packages("feasts")
You can install the development version from GitHub with:
# install.packages("remotes") remotes::install_github("tidyverts/feasts")
library(feasts) library(tsibble) library(tsibbledata) library(dplyr) library(ggplot2) library(lubridate)
Visualisation is often the first step in understanding the patterns in time series data. The package uses ggplot2 to produce customisable graphics to visualise time series patterns.
aus_production %>% gg_season(Beer) aus_production %>% gg_subseries(Beer) aus_production %>% filter(year(Quarter) > 1991) %>% gg_lag(Beer) aus_production %>% ACF(Beer) %>% autoplot()
A common task in time series analysis is decomposing a time series into some simpler components. The feasts package supports two common time series decomposition methods:
dcmp <- aus_production %>% model(STL(Beer ~ season(window = Inf))) components(dcmp)
components(dcmp) %>% autoplot()
Extract features and statistics across a large collection of time series to identify unusual/extreme time series, or find clusters of similar behaviour.
aus_retail %>% features(Turnover, feat_stl)
This allows you to visualise the behaviour of many time series (where the plotting methods above would show too much information).
aus_retail %>% features(Turnover, feat_stl) %>% ggplot(aes(x = trend_strength, y = seasonal_strength_year)) + geom_point() + facet_wrap(vars(State))
Most of Australian's retail industries are highly trended and seasonal for all states.
It's also easy to extract the most (and least) seasonal time series.
extreme_seasonalities <- aus_retail %>% features(Turnover, feat_stl) %>% filter(seasonal_strength_year %in% range(seasonal_strength_year)) aus_retail %>% right_join(extreme_seasonalities, by = c("State", "Industry")) %>% ggplot(aes(x = Month, y = Turnover)) + geom_line() + facet_grid(vars(State, Industry, scales::percent(seasonal_strength_year)), scales = "free_y")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.