Commit | Line | Data |
---|---|---|
3d69ff21 BA |
1 | #' @title Forecast |
2 | #' | |
3 | #' @description Forecast encapsulation | |
4 | #' | |
5 | #' @field pred List with | |
6 | #' \itemize{ | |
7 | #' \item serie: forecasted serie | |
8 | #' \item params: corresponding list of parameters (weights, neighbors...) | |
9 | #' \item index: corresponding index in data object | |
10 | #' } | |
11 | #' | |
12 | #' @exportClass Forecast | |
13 | #' @export Forecast | |
14 | Forecast = setRefClass( | |
15 | Class = "Forecast", | |
16 | ||
17 | fields = list( | |
18 | pred = "list" | |
19 | ), | |
20 | ||
21 | methods = list( | |
22 | initialize = function(...) | |
23 | { | |
24 | "Initialize empty Forecast object" | |
25 | ||
26 | callSuper(...) | |
27 | }, | |
28 | append = function(new_serie, new_params, new_index) | |
29 | { | |
30 | "Obtain a new pair (serie, params)" | |
31 | ||
32 | pred[[length(pred)+1]] <<- list("serie"=new_serie, "params"=new_params, "index"=new_index) | |
33 | }, | |
34 | getSize = function() | |
35 | { | |
36 | length(pred) | |
37 | }, | |
38 | getSerie = function(index) | |
39 | { | |
40 | "Get serie values at specified index" | |
41 | ||
42 | pred[[index]]$serie | |
43 | }, | |
44 | getParams = function(index) | |
45 | { | |
46 | "Get params at specified index" | |
47 | ||
48 | pred[[index]]$params | |
49 | }, | |
50 | getIndexInData = function(index) | |
51 | { | |
09cf9c19 | 52 | "Get (day) index in data where prediction took place" |
3d69ff21 BA |
53 | |
54 | pred[[index]]$index | |
55 | } | |
56 | ) | |
57 | ) |