fasster (version 0.1.0.9100)

FASSTER: 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

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 \((\theta^{(s)}t=\theta_t|D_T)\) to approximate correct behaviour

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

  4. Obtain state noise variances from the smoothed variance of \(w_t\): \(W=Var(w^{(s)}_t)=Var(\theta^{(s)}_t-G\theta^{(s)}_{t-1})\) Obtain measurement noise variance from smoothed variance of \(v_t\): \(V=Var(v^{(s)}_t)=Var(y_t-F_t\theta^{(s)}_t)\)

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

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.

Examples

Run this code
# NOT RUN {
cbind(mdeaths, fdeaths) %>%
  as_tsibble(pivot_longer = FALSE) %>%
  model(FASSTER(mdeaths ~ fdeaths + trend(1) + fourier(12)))

# }

Run the code above in your browser using DataCamp Workspace