1 #' Persistence Forecaster
3 #' Return the last centered (similar) day curve.
4 #' Inherits \code{\link{Forecaster}}
6 PersistenceForecaster = R6::R6Class("PersistenceForecaster",
10 predictShape = function(data, today, memory, horizon, ...)
12 # Return centered last (similar) day curve, avoiding NAs until memory is run
13 first_day = max(1, today-memory)
14 same_day = ifelse(hasArg("same_day"), list(...)$same_day, TRUE)
15 # If 'same_day', get the last known future of similar day: -7 + 1 == -6
16 index = today - ifelse(same_day,6,0)
20 last_serie = data$getCenteredSerie(index)[1:horizon]
21 index = index - ifelse(same_day,7,1)
23 if (!any(is.na(last_serie)))
25 if (index < first_day)