+++ /dev/null
-#' @include Forecaster.R
-#'
-#' @title Level Forecaster
-#'
-#' @description Return flat serie of last observed level. Inherits \code{\link{ShapeForecaster}}
-LevelForecaster = setRefClass(
- Class = "LevelForecaster",
- contains = "Forecaster",
-
- methods = list(
- initialize = function(...)
- {
- callSuper(...)
- },
- predict = function(today, memory, horizon, ...)
- {
- #return last day level
- first_day = max(1, today-memory)
- same_day = ifelse(hasArg("same_day"), list(...)$same_day, TRUE)
- index = today - ifelse(same_day,6,0)
- repeat
- {
- {
- last_serie = data$getSerie(index)[1:horizon]
- index = index - ifelse(same_day,7,1)
- };
- #TODO: next test is too strict
- if (!any(is.na(last_serie)))
- return (rep(mean(last_serie), horizon));
- if (index < first_day)
- return (NA)
- }
- }
- )
-)