1 #' @include Forecaster.R
3 #' @title Level Forecaster
5 #' @description Return flat serie of last observed level. Inherits \code{\link{ShapeForecaster}}
6 LevelForecaster = setRefClass(
7 Class = "LevelForecaster",
8 contains = "Forecaster",
11 initialize = function(...)
15 predict = function(today, memory, horizon, ...)
17 #return last day level
18 first_day = max(1, today-memory)
19 same_day = ifelse(hasArg("same_day"), list(...)$same_day, TRUE)
20 index = today - ifelse(same_day,6,0)
24 last_serie = data$getSerie(index)[1:horizon]
25 index = index - ifelse(same_day,7,1)
27 #TODO: next test is too strict
28 if (!any(is.na(last_serie)))
29 return (rep(mean(last_serie), horizon));
30 if (index < first_day)