#' @include ShapeForecaster.R #' #' @title Persistence Shape Forecaster #' #' @description Return the last centered last (similar) day curve. #' Inherits \code{\link{ShapeForecaster}} PersistenceShapeForecaster = setRefClass( Class = "PersistenceShapeForecaster", contains = "ShapeForecaster", methods = list( initialize = function(...) { callSuper(...) }, predict = 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) } } ) )