Description Usage Arguments Details Value Author(s) See Also Examples
Create a hybrid time series model with two to five component models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | hybridModel(
y,
models = "aefnst",
lambda = NULL,
a.args = NULL,
e.args = NULL,
n.args = NULL,
s.args = NULL,
t.args = NULL,
z.args = NULL,
weights = c("equal", "insample.errors", "cv.errors"),
errorMethod = c("RMSE", "MAE", "MASE"),
rolling = FALSE,
cvHorizon = frequency(y),
windowSize = 84,
horizonAverage = FALSE,
parallel = FALSE,
num.cores = 2L,
verbose = TRUE
)
|
y |
A numeric vector or time series. |
models |
A character string of up to seven characters indicating which contributing
models to use:
a ( |
lambda |
Box-Cox transformation parameter. Ignored if NULL. Otherwise, data transformed before model is estimated. |
a.args |
an optional |
e.args |
an optional |
n.args |
an optional |
s.args |
an optional |
t.args |
an optional |
z.args |
an optional |
weights |
method for weighting the forecasts of the various contributing
models. Defaults to |
errorMethod |
method of measuring accuracy to use if weights are not
to be equal.
Root mean square error ( |
rolling |
If |
cvHorizon |
If |
windowSize |
length of the window to build each model, only used when
|
horizonAverage |
If |
parallel |
a boolean indicating if parallel processing should be used between models.
Parallelization will still occur within individual models that support it and can be controlled
using |
num.cores |
If |
verbose |
Should the status of which model is being fit/cross validated be printed to the terminal? |
The hybridModel
function fits multiple individual model specifications
to allow easy creation of ensemble forecasts. While default settings for the individual
component models work quite well in most cases, fine control can be exerted by passing detailed
arguments to the component models in the
a.args
, e.args
, n.args
, s.args
, and t.args
lists.
Note that if xreg
is passed to the a.args
, n.args
, or
s.args
component models it must now be passed as a matrix. In "forecastHybrid"
versions earlier than 4.0.15 it would instead be passed in as a dataframe, but for consistency
with "forecast" v8.5 we now require a matrix with colnames
Characteristics of the input series can cause problems for certain types of models
and parameters. For example, stlm
models require that the input
series be seasonal; furthermore, the data must include at least two seasons
of data (i.e. length(y) >= 2 * frequency(y)
) for the decomposition to succeed.
If this is not the case, hybridModel()
will remove the stlm
model so an error does not occur.
Similarly, nnetar
models require that
length(y) >= 2 * frequency(y)
, so these models will be removed if the condition
is not satisfied. The ets
model does not handle
a series well with a seasonal period longer than 24 and will ignore the seasonality.
In this case, hybridModel()
will also drop the ets
model from the ensemble.
An object of class hybridModel. The individual component models are stored inside of the object and can be accessed for all the regular manipulations available in the forecast package.
David Shaub
forecast.hybridModel
, auto.arima
,
ets
, thetam
, nnetar
,
stlm
, tbats
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ## Not run:
# Fit an auto.arima, ets, thetam, nnetar, stlm, and tbats model
# on the time series with equal weights
mod1 <- hybridModel(AirPassengers)
plot(forecast(mod1))
# Use an auto.arima, ets, and tbats model with weights
# set by the MASE in-sample errors
mod2 <- hybridModel(AirPassengers, models = "aet",
weights = "insample.errors", errorMethod = "MASE")
# Pass additional arguments to auto.arima() to control its fit
mod3 <- hybridModel(AirPassengers, models = "aens",
a.args = list(max.p = 7, max.q = 7, approximation = FALSE))
# View the component auto.arima() and stlm() models
mod3$auto.arima
mod3$stlm
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.