Commit | Line | Data |
---|---|---|
e030a6e3 | 1 | #' Obtain jump forecast by the Persistence method |
3d69ff21 BA |
2 | #' |
3 | #' @inheritParams getForecast | |
e030a6e3 BA |
4 | #' @inheritParams getZeroJumpPredict |
5 | getPersistenceJumpPredict = function(data, today, memory, horizon, params, ...) | |
3d69ff21 | 6 | { |
09cf9c19 BA |
7 | #return gap between end of similar day curve and first day of tomorrow (in the past) |
8 | first_day = max(1, today-memory) | |
9 | index = today-7 | |
10 | repeat | |
11 | { | |
12 | { | |
13 | last_similar_serie_end = tail( data$getCenteredSerie(index), 1) | |
14 | last_similar_tomorrow_begin = data$getCenteredSerie(index+1)[1] | |
15 | index = index - 7 | |
16 | }; | |
17 | if (!is.na(last_similar_serie_end) && !is.na(last_similar_tomorrow_begin)) | |
18 | return (last_similar_tomorrow_begin - last_similar_serie_end); | |
19 | if (index < first_day) | |
20 | return (NA) | |
21 | } | |
3d69ff21 | 22 | } |