select_model: Select the optimal model

Description Usage Arguments Value Examples

View source: R/select_model.R

Description

double seasonal exponential smoothing method is implemented. If grid.search = TRUE, grid search is applied by searching parameters around the "first attempt" parameters. search.length and length.out are for grid search. The search is based on the minimum mean absolute percentage error with parallel computing. More details about parallel computing can be found in doParallel.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
select_model(
  train.y,
  valid.y = NULL,
  s1 = 7,
  s2 = 7 * 52,
  h = 2 * max(period1, period2),
  grid.search = FALSE,
  search.length = c(-0.5, 0.5),
  length.out = 5,
  CV = FALSE,
  kfold = NULL
)

Arguments

train.y

A numeric vector for training.

valid.y

A numeric vector for testing. If grid.search = NULL, valid.y = NULL.

s1

Period of the shorter seasonal period.

s2

Period of the longer seasonal period.

h

Number of periods for forecasting.

grid.search

If TRUE, a grid search is applied.

search.length

Grid search parameter. Only used if grid.search = TRUE. It is the proportion decreasing/increasing of the first attempt parameters. For example search.length = c(-0.5, 0.5), if the first attempt parameter is 0.1, then the searching window is from 0.1 * (1 - 0.5) to 0.1 * (1+ 0.5)

length.out

Grid search parameter. Only used if grid.search = TRUE. It is the desired length of search sequence.

CV

If TRUE, k-fold cross validation applied

kfold

The number of K-fold

Value

If grid.search = FALSE, an object of class forecast is return. Otherwise, a list contains:

Examples

1
2
3
4
5
6
data(tickets)
data.ls = train_test_split(tickets, var = "date", train.window = c(20140701, 20180630), test.window = c(20180701, 20190630))
train.y = data.ls$train.dat[,2]
valid.y = data.ls$test.dat[,2]
select.ls = select_model(train.y, valid.y, grid.search = TRUE, length.out = 2)
Double seasonal exponential time series cross validation

placeboo/amplify documentation built on Oct. 6, 2020, 9:04 a.m.