TODO: tests, reports
[talweg.git] / pkg / R / Forecast.R
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 getSize = function()
29 {
30 "Number of individual forecasts"
31
32 length(pred)
33 },
34 append = function(new_serie, new_params, new_index)
35 {
36 "Obtain a new pair (serie, params)"
37
38 pred[[length(pred)+1]] <<- list("serie"=new_serie, "params"=new_params, "index"=new_index)
39 },
40 getSerie = function(index)
41 {
42 "Serie values at specified index"
43
44 pred[[index]]$serie
45 },
46 getParams = function(index)
47 {
48 "Params at specified index"
49
50 pred[[index]]$params
51 },
52 getIndexInData = function(index)
53 {
54 "(day) Index in data where prediction took place"
55
56 pred[[index]]$index
57 }
58 )
59 )