1 #' getNeighborsJumpPredict
3 #' Apply optimized weights on gaps observed on selected neighbors.
4 #' This jump prediction method can only be used in conjunction with the Neighbors
5 #' Forecaster, because it makes use of the optimized parameters to re-apply the weights
6 #' on the jumps observed at days interfaces of the past neighbors.
8 #' @inheritParams computeForecast
9 #' @inheritParams getZeroJumpPredict
11 #' @aliases J_Neighbors
13 getNeighborsJumpPredict = function(data, today, memory, predict_from, horizon,
16 first_day = max(1, today-memory)
17 filter = (params$indices >= first_day)
18 indices = params$indices[filter]
19 weights = params$weights[filter]
21 if (is.na(indices[1]))
24 gaps = sapply(indices, function(i) {
25 if (predict_from >= 2)
26 data$getSerie(i)[predict_from] - data$getSerie(i)[predict_from-1]
28 head(data$getSerie(i),1) - tail(data$getSerie(i-1),1)
30 scal_product = weights * gaps
31 norm_fact = sum( weights[!is.na(scal_product)] )
32 sum(scal_product, na.rm=TRUE) / norm_fact