Description Usage Arguments Details Specials See Also Examples
Prepares a bsts model specification for use within the fable
package.
1 |
formula |
A symbolic description of the model to be fitted of class |
... |
Extra arguments to be passed to
|
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")
.
The intercept
special is used to specify the intercept parameters.
1 | intercept()
|
The ar
special is used to specify the autoregressive parameters.
1 |
lag | The number of lags ("p") in the AR(p) process. |
The level
special is used to specify the level parameters.
1 |
type | The type of level (local or shared). |
The trend
special is used to specify the trend parameters.
1 |
type | The type of trend (local linear, semi-local linear or student local linear). |
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". |
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. |
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. |
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 |
... | 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. |
bsts::bsts()
1 2 3 4 5 6 7 8 | if (requireNamespace("tsibbledata")) {
library(tsibble)
library(dplyr)
tsibbledata::aus_production %>%
model(
bsts = BSTS(Beer ~ season("year"))
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.