R/model.R
fasster-model.Rd
Implements FASSTER
FASSTER(formula, include = NULL, ...)
formula | An object of class "formula" (refer to 'Formula' for usage) |
---|---|
include | How many terms should be included to fit the model |
... | Not used |
Returns a mable containing the fitted FASSTER model.
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.
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)
The model parameters are estimated using the following heuristic:
Filter the data using the specified model with non-zero state variances
Obtain smoothed states \((\theta^{(s)}t=\theta_t|D_T)\) to approximate correct behaviour
The initial state parameters taken from the first smoothed state: \(m_0=E(\theta^{(s)}_0)\), \(C_0=Var(\theta^{(s)}_0)\)
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)\)
Repair restricted state variances for seasonal factors and ARMA terms
#> # A mable: 2 x 2 #> # Key: key [2] #> key `FASSTER(mdeaths ~ fdeaths + poly(1) + trig(12))` #> <chr> <model> #> 1 fdeaths <FASSTER> #> 2 mdeaths <FASSTER>