Commit | Line | Data |
---|---|---|
e030a6e3 | 1 | #' Obtain jump forecast by the Persistence method |
3d69ff21 | 2 | #' |
99f83c9a | 3 | #' @inheritParams computeForecast |
e030a6e3 | 4 | #' @inheritParams getZeroJumpPredict |
546b0cb6 | 5 | #' |
e030a6e3 | 6 | getPersistenceJumpPredict = function(data, today, memory, horizon, params, ...) |
3d69ff21 | 7 | { |
09cf9c19 BA |
8 | #return gap between end of similar day curve and first day of tomorrow (in the past) |
9 | first_day = max(1, today-memory) | |
e5aa669a | 10 | same_day = ifelse(hasArg("same_day"), list(...)$same_day, TRUE) |
72b9c501 | 11 | realtime = ifelse(hasArg("realtime"), list(...)$realtime, FALSE) |
e5aa669a | 12 | index = today - ifelse(same_day,7,1) |
09cf9c19 BA |
13 | repeat |
14 | { | |
15 | { | |
e5aa669a | 16 | last_serie_end = tail( data$getSerie(index), 1) |
72b9c501 | 17 | last_tomorrow_begin = data$getSerie(index+1,hat=(realtime && index+1==today))[1] |
e5aa669a | 18 | index = index - ifelse(same_day,7,1) |
09cf9c19 | 19 | }; |
e5aa669a BA |
20 | if (!is.na(last_serie_end) && !is.na(last_tomorrow_begin)) |
21 | return (last_tomorrow_begin - last_serie_end); | |
09cf9c19 BA |
22 | if (index < first_day) |
23 | return (NA) | |
24 | } | |
3d69ff21 | 25 | } |