Package 'fasster'

Title: Fast Additive Switching of Seasonality, Trend and Exogenous Regressors
Description: Implementation of the FASSTER model for forecasting time series with multiple seasonalities using switching states.
Authors: Mitchell O'Hara-Wild [aut, cre], Rob Hyndman [aut, ths]
Maintainer: Mitchell O'Hara-Wild <[email protected]>
License: GPL-3
Version: 0.1.0.9100
Built: 2024-11-01 03:24:45 UTC
Source: https://github.com/mitchelloharawild/fasster

Help Index


Fast Additive Switching of Seasonality, Trend and Exogenous Regressors

Description

Implementation of the FASSTER model for forecasting time series with multiple seasonalities using switching states.

Details

Package: fasster
Type: Package
License: GPL3
LazyLoad: yes

Author(s)

Mitchell O'Hara-Wild

Maintainer: [email protected]


Fast Additive Switching of Seasonality, Trend and Exogenous Regressors

Description

Implements FASSTER

Usage

FASSTER(formula, include = NULL, ...)

Arguments

formula

An object of class "formula" (refer to 'Formula' for usage)

include

How many terms should be included to fit the model

...

Not used

Details

The fasster model extends commonly used state space models by introducing a switching component to the measurement equation. This is implemented using a time-varying DLM with the switching behaviour encoded in the measurement matrix.

Value

Returns a mable containing the fitted FASSTER model.

Formula

fasster inherits the standard formula specification from lm for specifying exogenous regressors, including interactions and I() functionality as described in formula.

Special DLM components can be specified using special functions defined below:

  • seas(s): Creates seasonal factors with seasonal period s

  • fourier(s, K): Creates seasonal fourier terms with seasonal period s and K harmonics

  • poly(n): Creates a polynomial of order n (poly(1) creates a level, poly(2) creates a trend)

  • ARMA(ar, ma): Creates ARMA terms with coefficient vectors ar and ma

  • custom(dlm): Creates a custom dlm structure, using dlm

The switching operator, %S% requires the switching factor variable on the LHS, and the model to switch over on the RHS (as built using the above components)

Heuristic

The model parameters are estimated using the following heuristic:

  1. Filter the data using the specified model with non-zero state variances

  2. Obtain smoothed states (θ(s)t=θtDT)(\theta^{(s)}t=\theta_t|D_T) to approximate correct behaviour

  3. The initial state parameters taken from the first smoothed state: m0=E(θ0(s))m_0=E(\theta^{(s)}_0), C0=Var(θ0(s))C_0=Var(\theta^{(s)}_0)

  4. Obtain state noise variances from the smoothed variance of wtw_t: W=Var(wt(s))=Var(θt(s)Gθt1(s))W=Var(w^{(s)}_t)=Var(\theta^{(s)}_t-G\theta^{(s)}_{t-1}) Obtain measurement noise variance from smoothed variance of vtv_t: V=Var(vt(s))=Var(ytFtθt(s))V=Var(v^{(s)}_t)=Var(y_t-F_t\theta^{(s)}_t)

  5. Repair restricted state variances for seasonal factors and ARMA terms

Examples

cbind(mdeaths, fdeaths) %>%
  as_tsibble(pivot_longer = FALSE) %>%
  model(FASSTER(mdeaths ~ fdeaths + trend(1) + fourier(12)))

Extract coefficients from a FASSTER model

Description

Obtains the mean and variance of the estimated initial states from a FASSTER model. Values in the estimate column are contains the mean, and the std.error column contains the standard deviation of the initial states.

Usage

## S3 method for class 'FASSTER'
tidy(x, ...)

Arguments

x

An object containing a FASSTER model.

...

Unused.