X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2FR%2FcomputeError.R;h=c3bc4f381da34112eca28f339db3093582ed9d67;hb=1e8327df4e8abce5c23808be4f98037635bb2714;hp=1fbb2a8cd007c80368878da8849f0643da31f012;hpb=102bcfda4afbb5cfee885cbee0f55545624168fd;p=talweg.git diff --git a/pkg/R/computeError.R b/pkg/R/computeError.R index 1fbb2a8..c3bc4f3 100644 --- a/pkg/R/computeError.R +++ b/pkg/R/computeError.R @@ -13,20 +13,20 @@ #' step, averaged on the L forecasting days. #' #' @export -computeError = function(data, pred, horizon=data$getStdHorizon()) +computeError = function(data, pred, predict_from, horizon=length(data$getSerie(1))) { - L = forecast$getSize() - mape_day = rep(0, horizon) - abs_day = rep(0, horizon) + L = pred$getSize() + mape_day = rep(0, horizon-predict_from+1) + abs_day = rep(0, horizon-predict_from+1) mape_indices = rep(NA, L) abs_indices = rep(NA, L) nb_no_NA_data = 0 for (i in seq_len(L)) { - index = forecast$getIndexInData(i) - serie = data$getSerie(index+1)[1:horizon] - forecast = pred$getForecast(i)[1:horizon] + index = pred$getIndexInData(i) + serie = data$getSerie(index)[predict_from:horizon] + forecast = pred$getForecast(i)[predict_from:horizon] if (!any(is.na(serie)) && !any(is.na(forecast))) { nb_no_NA_data = nb_no_NA_data + 1