View source: R/parsniptemporal_hierarchy.R
temporal_hierarchy  R Documentation 
temporal_hierarchy()
is a way to generate a specification of an Temporal Hierarchical Forecasting model
before fitting and allows the model to be created using
different packages. Currently the only package is thief
. Note this
function requires the thief
package to be installed.
temporal_hierarchy( mode = "regression", seasonal_period = NULL, combination_method = NULL, use_model = NULL )
mode 
A single character string for the type of model. The only possible value for this model is "regression". 
seasonal_period 
A seasonal frequency. Uses "auto" by default. A character phrase of "auto" or timebased phrase of "2 weeks" can be used if a date or datetime variable is provided. See Fit Details below. 
combination_method 
Combination method of temporal hierarchies, taking one of the following values:

use_model 
Model used for forecasting each aggregation level:

Models can be created using the following engines:
"thief" (default)  Connects to thief::thief()
The standardized parameter names in modeltime
can be mapped to their original
names in each engine:
modeltime  thief::thief() 
combination_method  comb 
use_model  usemodel 
Other options can be set using set_engine()
.
thief (default engine)
The engine uses thief::thief()
.
Function Parameters:
## function (y, m = frequency(y), h = m * 2, comb = c("struc", "mse", "ols", ## "bu", "shr", "sam"), usemodel = c("ets", "arima", "theta", "naive", ## "snaive"), forecastfunction = NULL, aggregatelist = NULL, ...)
Other options and argument can be set using set_engine()
.
Parameter Notes:
xreg
 This model is not set up to use exogenous regressors. Only univariate
models will be fit.
Date and DateTime Variable
It's a requirement to have a date or datetime variable as a predictor.
The fit()
interface accepts date and datetime features and handles them internally.
fit(y ~ date)
Univariate:
For univariate analysis, you must include a date or datetime feature. Simply use:
Formula Interface (recommended): fit(y ~ date)
will ignore xreg's.
XY Interface: fit_xy(x = data[,"date"], y = data$y)
will ignore xreg's.
Multivariate (xregs, Exogenous Regressors)
This model is not set up for use with exogenous regressors.
For forecasting with temporal hierarchies see: Athanasopoulos G., Hyndman R.J., Kourentzes N., Petropoulos F. (2017) Forecasting with Temporal Hierarchies. European Journal of Operational research, 262(1), 6074.
For combination operators see: Kourentzes N., Barrow B.K., Crone S.F. (2014) Neural network ensemble operators for time series forecasting. Expert Systems with Applications, 41(9), 42354244.
fit.model_spec()
, set_engine()
library(dplyr) library(parsnip) library(rsample) library(timetk) library(modeltime) library(thief) # Data m750 < m4_monthly %>% filter(id == "M750") m750 # Split Data 80/20 splits < initial_time_split(m750, prop = 0.8) #  HIERARCHICAL  # Model Spec  The default parameters are all set # to "auto" if none are provided model_spec < temporal_hierarchy() %>% set_engine("thief") # Fit Spec model_fit < model_spec %>% fit(log(value) ~ date, data = training(splits)) model_fit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.