Description Usage Arguments Details Fit Details See Also Examples
adam_reg()
is a way to generate a specification of an ADAM model
before fitting and allows the model to be created using
different packages. Currently the only package is smooth
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  adam_reg(
mode = "regression",
ets_model = NULL,
non_seasonal_ar = NULL,
non_seasonal_differences = NULL,
non_seasonal_ma = NULL,
seasonal_ar = NULL,
seasonal_differences = NULL,
seasonal_ma = NULL,
use_constant = NULL,
regressors_treatment = NULL,
outliers_treatment = NULL,
outliers_ci = NULL,
probability_model = NULL,
distribution = NULL,
loss = NULL,
information_criteria = NULL,
seasonal_period = NULL,
select_order = NULL
)

mode 
A single character string for the type of model. The only possible value for this model is "regression". 
ets_model 
The type of ETS model. The first letter stands for the type of the error term ("A" or "M"), the second (and sometimes the third as well) is for the trend ("N", "A", "Ad", "M" or "Md"), and the last one is for the type of seasonality ("N", "A" or "M"). 
non_seasonal_ar 
The order of the nonseasonal autoregressive (AR) terms. Often denoted "p" in pdqnotation. 
non_seasonal_differences 
The order of integration for nonseasonal differencing. Often denoted "d" in pdqnotation. 
non_seasonal_ma 
The order of the nonseasonal moving average (MA) terms. Often denoted "q" in pdqnotation. 
seasonal_ar 
The order of the seasonal autoregressive (SAR) terms. Often denoted "P" in PDQnotation. 
seasonal_differences 
The order of integration for seasonal differencing. Often denoted "D" in PDQnotation. 
seasonal_ma 
The order of the seasonal moving average (SMA) terms. Often denoted "Q" in PDQnotation. 
use_constant 
Logical, determining, whether the constant is needed in the model or not. This is mainly needed for ARIMA part of the model, but can be used for ETS as well. 
regressors_treatment 
The variable defines what to do with the provided explanatory variables: "use" means that all of the data should be used, while "select" means that a selection using ic should be done, "adapt" will trigger the mechanism of time varying parameters for the explanatory variables. 
outliers_treatment 
Defines what to do with outliers: "ignore", so just returning the model, "detect" outliers based on specified level and include dummies for them in the model, or detect and "select" those of them that reduce ic value. 
outliers_ci 
What confidence level to use for detection of outliers. Default is 99%. 
probability_model 
The type of model used in probability estimation. Can be "none"  none, "fixed"  constant probability, "general"  the general Beta model with two parameters, "oddsratio"  the Oddsratio model with b=1 in Beta distribution, "inverseoddsratio"  the model with a=1 in Beta distribution, "direct"  the TSBlike (Teunter et al., 2011) probability update mechanism a+b=1, "auto"  the automatically selected type of occurrence model. 
distribution 
what density function to assume for the error term. The full name of the distribution should be provided, starting with the letter "d"  "density". 
loss 
The type of Loss Function used in optimization. 
information_criteria 
The information criterion to use in the model selection / combination procedure. 
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. 
select_order 
If TRUE, then the function will select the most appropriate order. The values list(ar=...,i=...,ma=...) specify the maximum orders to check in this case. 
The data given to the function are not saved and are only used
to determine the mode of the model. For adam_reg()
, the
mode will always be "regression".
The model can be created using the fit()
function using the
following engines:
"auto_adam" (default)  Connects to smooth::auto.adam()
"adam"  Connects to smooth::adam()
Main Arguments
The main arguments (tuning parameters) for the model are:
seasonal_period
: The periodic nature of the seasonality. Uses "auto" by default.
non_seasonal_ar
: The order of the nonseasonal autoregressive (AR) terms.
non_seasonal_differences
: The order of integration for nonseasonal differencing.
non_seasonal_ma
: The order of the nonseasonal moving average (MA) terms.
seasonal_ar
: The order of the seasonal autoregressive (SAR) terms.
seasonal_differences
: The order of integration for seasonal differencing.
seasonal_ma
: The order of the seasonal moving average (SMA) terms.
ets_model
: The type of ETS model.
use_constant
: Logical, determining, whether the constant is needed in the model or not.
regressors_treatment
: The variable defines what to do with the provided explanatory variables.
outliers_treatment
: Defines what to do with outliers.
probability_model
: The type of model used in probability estimation.
distribution
: what density function to assume for the error term.
loss
: The type of Loss Function used in optimization.
information_criteria
: The information criterion to use in the model selection / combination procedure.
These arguments are converted to their specific names at the time that the model is fit.
Other options and argument can be
set using set_engine()
(See Engine Details below).
If parameters need to be modified, update()
can be used
in lieu of recreating the object from scratch.
auto_adam (default engine)
The engine uses smooth::auto.adam()
.
Function Parameters:
1 2 3  ## Registered S3 method overwritten by 'greybox':
## method from
## print.pcor lava

1 2 3 4 5 6 7 8 9  ## function (data, model = "ZXZ", lags = c(frequency(data)), orders = list(ar = c(0),
## i = c(0), ma = c(0), select = FALSE), formula = NULL, outliers = c("ignore",
## "use", "select"), level = 0.99, distribution = c("dnorm", "dlaplace",
## "ds", "dgnorm", "dlnorm", "dinvgauss", "dgamma"), h = 0, holdout = FALSE,
## persistence = NULL, phi = NULL, initial = c("optimal", "backcasting"),
## arma = NULL, occurrence = c("none", "auto", "fixed", "general", "oddsratio",
## "inverseoddsratio", "direct"), ic = c("AICc", "AIC", "BIC", "BICc"),
## bounds = c("usual", "admissible", "none"), regressors = c("use", "select",
## "adapt"), silent = TRUE, parallel = FALSE, ...)

The MAXIMUM nonseasonal ARIMA terms (max.p
, max.d
, max.q
) and
seasonal ARIMA terms (max.P
, max.D
, max.Q
) are provided to
forecast::auto.arima()
via arima_reg()
parameters.
Other options and argument can be set using set_engine()
.
Parameter Notes:
All values of nonseasonal pdq and seasonal PDQ are maximums.
The smooth::auto.adam()
model will select a value using these as an upper limit.
xreg
 This is supplied via the parsnip / modeltime fit()
interface
(so don't provide this manually). See Fit Details (below).
adam
The engine uses smooth::adam()
.
Function Parameters:
1 2 3 4 5 6 7 8 9 10 11  ## function (data, model = "ZXZ", lags = c(frequency(data)), orders = list(ar = c(0),
## i = c(0), ma = c(0), select = FALSE), constant = FALSE, formula = NULL,
## regressors = c("use", "select", "adapt"), outliers = c("ignore", "use",
## "select"), level = 0.99, occurrence = c("none", "auto", "fixed",
## "general", "oddsratio", "inverseoddsratio", "direct"), distribution = c("default",
## "dnorm", "dlaplace", "ds", "dgnorm", "dlnorm", "dinvgauss", "dgamma"),
## loss = c("likelihood", "MSE", "MAE", "HAM", "LASSO", "RIDGE", "MSEh",
## "TMSE", "GTMSE", "MSCE"), h = 0, holdout = FALSE, persistence = NULL,
## phi = NULL, initial = c("optimal", "backcasting"), arma = NULL, ic = c("AICc",
## "AIC", "BIC", "BICc"), bounds = c("usual", "admissible", "none"),
## silent = TRUE, ...)

The nonseasonal ARIMA terms (orders
) and seasonal ARIMA terms (orders
)
are provided to smooth::adam()
via adam_reg()
parameters.
Other options and argument can be set using set_engine()
.
Parameter Notes:
xreg
 This is supplied via the parsnip / modeltime fit()
interface
(so don't provide this manually). See Fit Details (below).
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)
Seasonal Period Specification
The period can be nonseasonal (seasonal_period = 1 or "none"
) or
yearly seasonal (e.g. For monthly time stamps, seasonal_period = 12
, seasonal_period = "12 months"
, or seasonal_period = "yearly"
).
There are 3 ways to specify:
seasonal_period = "auto"
: A seasonal period is selected based on the periodicity of the data (e.g. 12 if monthly)
seasonal_period = 12
: A numeric frequency. For example, 12 is common for monthly data
seasonal_period = "1 year"
: A timebased phrase. For example, "1 year" would convert to 12 for monthly data.
Univariate (No xregs, Exogenous Regressors):
For univariate analysis, you must include a date or datetime feature. Simply use:
Formula Interface (recommended): fit(y ~ date)
will ignore xreg's.
Multivariate (xregs, Exogenous Regressors)
The xreg
parameter is populated using the fit()
function:
Only factor
, ordered factor
, and numeric
data will be used as xregs.
Date and Datetime variables are not used as xregs
character
data should be converted to factor.
Xreg Example: Suppose you have 3 features:
y
(target)
date
(time stamp),
month.lbl
(labeled month as a ordered factor).
The month.lbl
is an exogenous regressor that can be passed to the arima_reg()
using
fit()
:
fit(y ~ date + month.lbl)
will pass month.lbl
on as an exogenous regressor.
Note that date or datetime class values are excluded from xreg
.
fit.model_spec()
, set_engine()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47  ## Not run:
library(dplyr)
library(parsnip)
library(rsample)
library(timetk)
library(modeltime)
library(smooth)
# Data
m750 < m4_monthly %>% filter(id == "M750")
m750
# Split Data 80/20
splits < initial_time_split(m750, prop = 0.8)
#  AUTO ADAM 
# Model Spec
model_spec < adam_reg() %>%
set_engine("auto_adam")
# Fit Spec
model_fit < model_spec %>%
fit(log(value) ~ date, data = training(splits))
model_fit
#  STANDARD ADAM 
# Model Spec
model_spec < adam_reg(
seasonal_period = 12,
non_seasonal_ar = 3,
non_seasonal_differences = 1,
non_seasonal_ma = 3,
seasonal_ar = 1,
seasonal_differences = 0,
seasonal_ma = 1
) %>%
set_engine("adam")
# Fit Spec
model_fit < model_spec %>%
fit(log(value) ~ date, data = training(splits))
model_fit
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.