X-Git-Url: https://git.auder.net/?p=talweg.git;a=blobdiff_plain;f=pkg%2FR%2FcomputeError.R;fp=pkg%2FR%2FcomputeError.R;h=db5783e6f6271ccc309fe32cd576db6d87dd379c;hp=3aa028fb88282b41a4f55b92545f1de030e8dd94;hb=af718fd5a9a330b13b331e78824a47407a3479ae;hpb=c8a81efd2e8302cde424165539f49e4bb7466fc3 diff --git a/pkg/R/computeError.R b/pkg/R/computeError.R index 3aa028f..db5783e 100644 --- a/pkg/R/computeError.R +++ b/pkg/R/computeError.R @@ -4,8 +4,10 @@ #' #' @param data Object of class \code{Data} output of \code{getData} #' @param pred Object of class \code{Forecast} output of \code{computeForecast} -#' @param horizon Horizon where to compute the error -#' (<= horizon used in \code{computeForecast}) +#' @param predict_from First time step to consider (>= predict_from used in +#' \code{computeForecast()}) +#' @param horizon Horizon where to compute the error (<= horizon used in +#' \code{computeForecast}) #' #' @return A list (abs,MAPE) of lists (day,indices). The "indices" slots contain series #' of size L where L is the number of predicted days; i-th value is the averaged error @@ -13,11 +15,11 @@ #' 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 = pred$getSize() - mape_day = rep(0, horizon) - abs_day = rep(0, horizon) + 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) @@ -25,8 +27,8 @@ computeError = function(data, pred, horizon=data$getStdHorizon()) for (i in seq_len(L)) { index = pred$getIndexInData(i) - serie = data$getSerie(index+1)[1:horizon] - forecast = pred$getForecast(i)[1:horizon] + 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