fixes and improvements
[talweg.git] / R / Data.R
CommitLineData
3d69ff21
BA
1#' @title Data
2#'
3#' @description Data encapsulation
4#'
5#' @field data List of
6#' \itemize{
7#' \item time: vector of times
8#' \item serie: centered series
9#' \item level: corresponding levels
10#' \item exo_hat: predicted exogenous variables
11#' \item exo_Dm1: List of measured exogenous variables at day minus 1
12#' }
13#'
14#' @exportClass Data
15#' @export Data
16Data = setRefClass(
17 Class = "Data",
18
19 fields = list(
20 data = "list"
21 ),
22
23 methods = list(
24 initialize = function(...)
25 {
26 "Initialize empty Data object"
27
28 callSuper(...)
29 },
30 getSize = function()
31 {
32 length(data)
33 },
34 append = function(new_time, new_serie, new_level, new_exo_hat, new_exo_Dm1)
35 {
36 "Acquire a new vector of lists (time, serie, level, exo_hat, exo_Dm1)"
37
38 data[[length(data)+1]] <<- list("time"=new_time,"serie"=new_serie,"level"=new_level,
39 "exo_hat"=new_exo_hat,"exo_Dm1"=new_exo_Dm1)
40 },
41 getTime = function(index)
42 {
43 "Get time values at specified index"
44
09cf9c19 45 index = dateIndexToInteger(index, .self)
3d69ff21
BA
46 data[[index]]$time
47 },
48 getCenteredSerie = function(index)
49 {
50 "Get serie values (centered) at specified index"
51
09cf9c19 52 index = dateIndexToInteger(index, .self)
3d69ff21
BA
53 data[[index]]$serie
54 },
55 getLevel = function(index)
56 {
57 "Get level for the serie at specified index"
58
09cf9c19 59 index = dateIndexToInteger(index, .self)
3d69ff21
BA
60 data[[index]]$level
61 },
62 getSerie = function(index)
63 {
64 "Get serie values (centered+level) at specified index"
65
09cf9c19 66 index = dateIndexToInteger(index, .self)
3d69ff21
BA
67 data[[index]]$serie + data[[index]]$level
68 },
69 getExoHat = function(index)
70 {
71 "Get exogeous predictions at specified index"
72
09cf9c19 73 index = dateIndexToInteger(index, .self)
3d69ff21
BA
74 data[[index]]$exo_hat
75 },
76 getExoDm1 = function(index)
77 {
78 "Get exogenous measures the day before specified index"
79
09cf9c19 80 index = dateIndexToInteger(index, .self)
3d69ff21
BA
81 data[[index]]$exo_Dm1
82 }
83 )
84)