3 #' @description Obtain the errors between forecast and data
5 #' @param data Dataset, object of class \code{Data} output of \code{getData}
6 #' @param forecast Forecast object, class \code{Forecast} output of \code{computeForecast}
7 #' @param horizon Horizon where to compute the error (<= horizon used in \code{computeForecast})
9 #' @return A list (abs,MAPE) of lists (day,indices)
12 computeError = function(data, forecast, horizon=data$getStdHorizon())
14 L = forecast$getSize()
15 mape_day = rep(0, horizon)
16 abs_day = rep(0, horizon)
17 mape_indices = rep(NA, L)
18 abs_indices = rep(NA, L)
23 index = forecast$getIndexInData(i)
24 serie = data$getSerie(index+1)[1:horizon]
25 pred = forecast$getSerie(i)[1:horizon]
26 if (!any(is.na(serie)) && !any(is.na(pred)))
28 nb_no_NA_data = nb_no_NA_data + 1
29 mape_increment = abs(serie - pred) / serie
30 mape_increment[is.nan(mape_increment)] = 0. # 0 / 0
31 mape_increment[!is.finite(mape_increment)] = 1. # >0 / 0
32 mape_day = mape_day + mape_increment
33 abs_increment = abs(serie - pred)
34 abs_day = abs_day + abs_increment
35 mape_indices[i] = mean(mape_increment)
36 abs_indices[i] = mean(abs_increment)
42 "day" = abs_day / nb_no_NA_data,
43 "indices" = abs_indices),
45 "day" = mape_day / nb_no_NA_data,
46 "indices" = mape_indices) )