3 #' Forecast encapsulation
6 #' @importFrom R6 R6Class
8 #' @field .pred List with \itemize{
9 #' \item serie: forecasted serie
10 #' \item params: corresponding list of parameters (weights, neighbors...)
11 #' \item index: corresponding index in data object}
12 #' @field .dates vector of day indices where forcast occurs
14 #' @section Methods: \describe{
15 #' \item{\code{initialize(dates)}}
16 #' {Initialize a Forecast object with a series of date indices.}
17 #' \item{\code{getSize()}}
18 #' {Return number of individual forecasts.}
19 #' \item{\code{append(new_serie, new_params, new_index_in_data)}}
20 #' {Acquire a new individual forecast, with its (optimized) parameters and the corresponding
21 #' index in the dataset.}
22 #' \item{\code{getDates()}}
23 #' {Get dates where forecast occurs.}
24 #' \item{\code{getSerie(index)}}
25 #' {Get forecasted serie at specified index.}
26 #' \item{\code{getParams(index)}}
27 #' {Get parameters at specified index (for 'Neighbors' method).}
28 #' \item{\code{getIndexInData(index)}}
29 #' {Get index in data which corresponds to current forecast.}}
30 Forecast = R6::R6Class("Forecast",
36 initialize = function(dates)
38 private$.dates <- dates
44 append = function(new_serie, new_params, new_index_in_data)
46 private$.pred[[length(private$.pred)+1]] <-
47 list("serie"=new_serie, "params"=new_params, "index_in_data"=new_index_in_data)
52 getSerie = function(index)
55 index = match(index, private$.dates)
56 private$.pred[[index]]$serie
58 getParams = function(index)
61 index = match(index, private$.dates)
62 private$.pred[[index]]$params
64 getIndexInData = function(index)
67 index = match(index, private$.dates)
68 private$.pred[[index]]$index_in_data