Description Usage Arguments Details Value Author(s) Examples
This algorithm will search for the "best" size of the rolling sample and the "best" number of rolling samples. "Best" in the sense of minimizing the selected error measure.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | gears_optim(
DATA,
forecast.horizon,
search.size.rs,
search.number.rs,
glm.family = c("gaussian", "binomial", "poisson", "Gamma", "quasi"),
level = 95,
details = FALSE,
y.name = NULL,
y.max.lags = NULL,
x.names = NULL,
x.max.lags = NULL,
x.fixed.names = NULL,
x.fixed.lags = NULL,
x.interaction.names = NULL,
x.interaction.lags = NULL,
last.obs = NULL,
use.intercept = c("both", "without", "with"),
error.measure = c("mse", "mae", "mase", "smape", "owa"),
betas.selection = c("last", "average", "both"),
use.parallel = FALSE,
num.cores = NULL,
...
)
|
DATA |
A data frame or a univariate time series. |
forecast.horizon |
Number of periods for forecasting. |
search.size.rs |
Vector with the number of observations in the rolling sample to be optimized. |
search.number.rs |
Vector with the number of rolling samples to be optimized. |
glm.family |
A description of the error distribution to be used in the model. See glm for details. |
level |
Confidence level for prediction intervals. Numeric value between 0 and 100. |
details |
If |
y.name |
The name of the Y (left-hand side) variable. If NULL (default), the function creates a temporary name. |
y.max.lags |
A numeric value that gives the maximum number of lags of the Y (left-hand side) variable (see Details). Can be NULL (default) if the past values of the Y variable are not included in the model. |
x.names |
List with names of the X (right-hand side) variables that have a maximum number of lags (see Details). Can be NULL (default) if univariate model or if your model does not have variables of this type. |
x.max.lags |
List of numeric values that give the maximum number of lags of the X (right-hand side) variables. Can be NULL (default). |
x.fixed.names |
List with names of the X (right-hand side) variables that have a fixed number of lags (see Details). Can be NULL (default) if univariate model or if your model does not have variables of this type. |
x.fixed.lags |
List of numeric values that give the fixed number of lags of the variables in x.fixed.names. Can be NULL (default). |
x.interaction.names |
List of character vectors with names of the variables to be included as interaction terms (see Details). Can be NULL (default) if your model does not have interaction terms. |
x.interaction.lags |
List of numeric vectors with lags of the variables to be included as interaction terms. List and numeric vectors should have the same length as the ones in x.interaction.names. Can be NULL (default) if your model does not have interaction terms. |
last.obs |
Index number of the last observation to be considered. |
use.intercept |
If |
error.measure |
Error measure to be used when calculating the in-sample prediction errors. |
betas.selection |
If |
use.parallel |
If parallel computing should be used. Default is
|
num.cores |
Number of cores to use if parallel computing is used.
If |
... |
Further arguments passed to glm. |
If y.max.lags
equals to a number, then all lags of
y.name
up to this number (and starting at 0) will be included
in the list of variables to enter the right-hand side of the model
equations. For example, if y.max.lags = 2
, then
Yt, Yt-1, Yt-2
will be included in the list of variables
to enter the right-hand side of the equation.
A data frame with five columns: "size.rs", "number.rs", "intercept",
"betas" and the last one named after the selected error measure. The last
column returns the minimum value for the selected error measure, and the
columns "size.rs" and "number.rs" return the sample sizes and the number
of rolling samples used to get this minimum. The column "intercept" gives
information on whether the intercept was used ("with"), or not
("without") on the best model. The "betas" column tells which
betas.selection
returns the best results.
Gustavo Varela-Alvarenga
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | # Univariate Time Series Forecasting - Data of class 'ts'.
# Using betas.selection = "last"
gears_optim(
DATA = datasets::WWWusage,
forecast.horizon = 12,
search.size.rs = c(20, 30),
search.number.rs = c(10, 12),
level = 95,
details = FALSE,
glm.family = "quasi",
y.name = NULL,
y.max.lags = 2,
x.names = NULL,
x.max.lags = NULL,
x.fixed.names = NULL,
x.fixed.lags = NULL,
x.interaction.names = NULL,
x.interaction.lags = NULL,
last.obs = length(datasets::WWWusage),
use.intercept = "both",
error.measure = "mse",
betas.selection = "last",
use.parallel = FALSE,
num.cores = NULL
)
# Univariate Time Series Forecasting - Data of class 'ts'.
# Using betas.selection = "both"
gears_optim(
DATA = datasets::WWWusage,
forecast.horizon = 12,
search.size.rs = c(20, 30),
search.number.rs = c(10, 12),
level = 95,
details = FALSE,
glm.family = "quasi",
y.name = NULL,
y.max.lags = 2,
x.names = NULL,
x.max.lags = NULL,
x.fixed.names = NULL,
x.fixed.lags = NULL,
x.interaction.names = NULL,
x.interaction.lags = NULL,
last.obs = length(datasets::WWWusage),
use.intercept = "both",
error.measure = "mse",
betas.selection = "both",
use.parallel = FALSE,
num.cores = NULL
)
gears_optim(
DATA = datasets::WWWusage,
forecast.horizon = 12,
search.size.rs = c(20, 30),
search.number.rs = c(10, 12),
level = 95,
details = FALSE,
glm.family = "quasi",
y.name = NULL,
y.max.lags = 2,
x.names = NULL,
x.max.lags = NULL,
x.fixed.names = NULL,
x.fixed.lags = NULL,
x.interaction.names = NULL,
x.interaction.lags = NULL,
last.obs = length(datasets::WWWusage),
use.intercept = "with",
error.measure = "mse",
betas.selection = "both",
use.parallel = FALSE,
num.cores = NULL
)
# With Parallel Computing
# Univariate Time Series Forecasting - Data of class 'ts'.
## If num.cores = NULL, the function uses
## num.cores = parallel::detectCores() - 1
gears_optim(
DATA = datasets::WWWusage,
forecast.horizon = 12,
search.size.rs = c(20, 30),
search.number.rs = c(10, 12),
level = 95,
glm.family = "quasi",
y.max.lags = 2,
use.intercept = "both",
error.measure = "mse",
betas.selection = "last",
use.parallel = TRUE,
num.cores = NULL
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.