3 #' Pointwise average of all the series of the same day of week in the past.
5 #' For example, if the current day (argument "today") is a tuesday, then all series
6 #' corresponding to wednesdays in the past (until the beginning or memory limit) are
7 #' averaged to provide a smooth prediction. This forecast will most of the time be wrong,
8 #' but will also look plausible enough.
11 #' @format R6 class, inherits Forecaster
14 AverageForecaster = R6::R6Class("AverageForecaster",
18 predictShape = function(data, today, memory, horizon, ...)
20 avg = rep(0., horizon)
21 first_day = max(1, today-memory)
27 serie_on_horizon = data$getCenteredSerie(index)[1:horizon]
30 if (!any(is.na(serie_on_horizon)))
32 avg = avg + serie_on_horizon
33 nb_no_na_series = nb_no_na_series + 1
35 if (index < first_day)