BSTS: bsts procedure modelling

Description Usage Arguments Details Specials See Also Examples

View source: R/model.R

Description

Prepares a bsts model specification for use within the fable package.

Usage

1

Arguments

formula

A symbolic description of the model to be fitted of class formula.

...

Extra arguments to be passed to SpikeSlabPrior (see the entry for the prior argument, above).

Details

The bsts modelling interface uses a formula based model specification (y ~ x), where the left of the formula specifies the response variable, and the right specifies the model's predictive terms. Like any model in the fable framework, it is possible to specify transformations on the response.

A bsts model supports local and semi-local linear trends, local levels with a random walk trend, additive seasonality and exogenous regressors. These can be specified using the 'specials' functions detailed below. The introduction vignette provides more details on how to model data using this interface to bsts: vignette("intro", package="fable.bsts").

Specials

intercept

The intercept special is used to specify the intercept parameters.

1
intercept()

ar

The ar special is used to specify the autoregressive parameters.

1
ar(lag = NULL)
lag The number of lags ("p") in the AR(p) process.

level

The level special is used to specify the level parameters.

1
level(type = c("local", "shared"))
type The type of level (local or shared).

trend

The trend special is used to specify the trend parameters.

1
trend(type = c("locallinear", "semilocallinear", "studentlocallinear"))
type The type of trend (local linear, semi-local linear or student local linear).

seasonal

The seasonal special is used to specify a seasonal component. This special can be used multiple times for different seasonalities.

Warning: Numeric inputs are treated as the number of observations in each seasonal period, not the number of days.

1
seasonal(period = NULL)
period The periodic nature of the seasonality. If a number is given, it will specify the number of observations in each seasonal period. If a character is given, it will be parsed using lubridate::as.period, allowing seasonal periods such as "2 years".

trig

The trig special is used to specify a trigonometric seasonal component. This special can be used multiple times for different seasonalities.

Warning: Numeric inputs are treated as the number of observations in each seasonal period, not the number of days.

1
trig(period = NULL, frequencies = 1)
period The length of the longest cycle. If a number is given, it will specify the number of observations in each seasonal period. If a character is given, it will be parsed using lubridate::as.period, allowing seasonal periods such as "2 years".
frequencies A vector of positive real numbers giving the number of times each cyclic component repeats in a period. One sine and one cosine term will be added for each frequency.

holiday

The holiday special is used to specify a tsibble containing holidays for the model.

1
holiday(holidays = NULL)
holidays A tsibble containing a set of holiday events. The event name is given in the 'holiday' column, and the event date is given via the index. Additionally, "lower_window" and "upper_window" columns can be used to include days before and after the holiday.

xreg

The xreg special is used to include exogenous regressors in the model. This special can be used multiple times for different regressors with different arguments. Exogenous regressors can also be used in the formula without explicitly using the xreg() special, which will then use the default arguments.

1
xreg(..., prior_scale = NULL, standardize = "auto", type = NULL)
... A set of bare expressions that are evaluated as exogenous regressors
standardize Should the regressor be standardised before fitting? If "auto", it will standardise if the regressor is not binary.

See Also

Examples

1
2
3
4
5
6
7
8
if (requireNamespace("tsibbledata")) {
library(tsibble)
library(dplyr)
tsibbledata::aus_production %>%
  model(
    bsts = BSTS(Beer ~ season("year"))
  )
}

davidtedfordholt/fable.bsts documentation built on Sept. 15, 2020, 11:38 a.m.