1 #' @include Forecaster.R
3 #' @title Level Forecaster
5 #' @description Return flat serie of last observed level (on similar day).
6 #' Inherits \code{\link{ShapeForecaster}}
7 LevelForecaster = setRefClass(
8 Class = "LevelForecaster",
9 contains = "Forecaster",
12 initialize = function(...)
16 predict = function(today, memory, horizon, all_memory=TRUE, ...)
18 #return last (similar) day level, or on all memory if all_memory==TRUE
19 first_day = max(1, today-memory)
29 last_similar_serie = data$getSerie(index)[1:horizon]
32 #TODO: next test is too strict
33 if (!any(is.na(last_similar_serie)))
37 sum_level = sum_level + mean(last_similar_serie)
38 nb_series = nb_series + 1
41 return (rep(mean(last_similar_serie), horizon))
43 if (index < first_day)
46 return (rep(sum_level / nb_series, horizon))