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

prophet(formula, ...)

Arguments

formula

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

...

Additional arguments passed to the optimizing or sampling functions in Stan.

Details

The prophet 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 prophet model supports piecewise linear or exponential growth (trend), additive or multiplicative seasonality, holiday effects 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 prophet: vignette("intro", package="fable.prophet").

Specials

growth

The growth special is used to specify the trend parameters.

growth(type = c("linear", "logistic"), capacity = NULL, floor = NULL,
       changepoints = NULL, n_changepoints = 25, changepoint_range = 0.8,
       changepoint_prior_scale = 0.05)
typeThe type of trend (linear or logistic).
capacityThe carrying capacity for when type is "logistic".
floorThe saturating minimum for when type is "logistic".
changepointsA vector of dates/times for changepoints. If NULL, changepoints are automatically selected.
n_changepointsThe total number of changepoints to be selected if changepoints is NULL
changepoint_rangeProportion of the start of the time series where changepoints are automatically selected.
changepoint_prior_scaleControls the flexibility of the trend.

season

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

Warning: The inputs controlling the seasonal period is specified is different than prophet::prophet(). Numeric inputs are treated as the number of observations in each seasonal period, not the number of days.

season(period = NULL, order = NULL, prior_scale = 10,
       type = c("additive", "multiplicative"), name = NULL)
periodThe 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".
orderThe number of terms in the partial Fourier sum. The higher the order, the more flexible the seasonality can be.
prior_scaleUsed to control the amount of regularisation applied. Reducing this will dampen the seasonal effect.
typeThe nature of the seasonality. If "additive", the variability in the seasonal pattern is fixed. If "multiplicative", the seasonal pattern varies proportionally to the level of the series.
nameThe name of the seasonal term (allowing you to name an annual pattern as 'annual' instead of 'year' or 365.25 for example).

holiday

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

holiday(holidays = NULL, prior_scale = 10L)
holidaysA 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.
prior_scaleUsed to control the amount of regularisation applied. Reducing this will dampen the holiday effect.

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.

xreg(..., prior_scale = NULL, standardize = "auto", type = NULL)
...A set of bare expressions that are evaluated as exogenous regressors
prior_scaleUsed to control the amount of regularisation applied. Reducing this will dampen the regressor effect.
standardizeShould the regressor be standardised before fitting? If "auto", it will standardise if the regressor is not binary.
typeDoes the effect of the regressor vary proportionally to the level of the series? If so, "multiplicative" is best. Otherwise, use "additive"

See also

Examples

library(tsibble) as_tsibble(USAccDeaths) %>% model( prophet = prophet(value ~ season("year", 4, type = "multiplicative")) )
#> # A mable: 1 x 1 #> prophet #> <model> #> 1 <prophet>