getBestModel {autoTS} | R Documentation |
Implement selected algorithms, train them without the last n observed data points (or n_test number of points), and compares the results to reality to determine the best algorithm
getBestModel(
dates,
values,
freq,
complete = 0,
n_test = NA,
graph = TRUE,
algos = list("my.prophet", "my.ets", "my.sarima", "my.tbats", "my.bats", "my.stlm",
"my.shortterm"),
bagged = "auto",
metric.error = my.rmse
)
dates |
A vector of dates that can be parsed by lubridate |
values |
A vector of same size as |
freq |
A chacracter string that indicates the frequency of the time series ("week", "month", "quarter", "day"). |
complete |
A numerical value (or NA) to fill the missing data points |
n_test |
number of data points to keep aside for the test (default : one year) |
graph |
A boolean, if TRUE, comparison of algorithms is plotted |
algos |
A list containing the algorithms (strings, with prefix "my.") to be tested |
bagged |
A string. "auto" will use all available algoriths, skipping algos parameter. Else, specified algos of the 'algo' parameter will be used |
metric.error |
a function to compute the error the each models. available functions : my.rmse and my.mae |
A list contraining a character string with the name of the best method, a gg object with the comparison between algorithms and a dataframe with predictions of all tried algorithms, a dtaframe containing the errors of each algorithms, the preparedTS object and the list of algorithms tested
library(autoTS)
dates <- seq(lubridate::as_date("2005-01-01"),lubridate::as_date("2010-12-31"),"quarter")
values <- 10+ 1:length(dates)/10 + rnorm(length(dates),mean = 0,sd = 10)
which.model <- getBestModel(dates,values,freq = "quarter",n_test = 4)
### Custom set of algorithm (including for bagged estimator)
which.model <- getBestModel(dates,values,freq = "quarter",n_test = 4,
algos = list("my.prophet","my.ets"),bagged = "custom")
### Use MAE instead of RMSE
which.model <- getBestModel(dates,values,freq = "quarter",n_test = 3,
algos = list("my.prophet","my.ets"),
bagged = "custom",metric.error = my.mae)