#' @include Forecaster.R #' #' @title Persistence Forecaster #' #' @description Return the last centered last (similar) day curve. #' Inherits \code{\link{Forecaster}} PersistenceForecaster = setRefClass( Class = "PersistenceForecaster", contains = "Forecaster", methods = list( initialize = function(...) { callSuper(...) }, predictShape = function(today, memory, horizon, ...) { #return centered last (similar) day curve, avoiding NAs until memory is run first_day = max(1, today-memory) index = today-7 + 1 repeat { { last_similar_serie = data$getCenteredSerie(index)[1:horizon] index = index - 7 }; if (!any(is.na(last_similar_serie))) return (last_similar_serie); if (index < first_day) return (NA) } } ) )