#' Obtain delta forecast by the Neighbors method #' #' @inheritParams getForecast #' @inheritParams getZeroDeltaForecast getNeighborsDeltaForecast = function(data, today, memory, horizon, shape_params, ...) { if (any(is.na(shape_params$weights) | is.na(shape_params$indices))) return (NA) gaps = sapply(shape_params$indices, function(i) { data$getSerie(i+1)[1] - tail(data$getSerie(i), 1) }) scal_product = shape_params$weights * gaps norm_fact = sum( shape_params$weights[!is.na(scal_product)] ) sum(scal_product, na.rm=TRUE) / norm_fact }