fix computeError.R
[talweg.git] / pkg / R / computeError.R
index ce05fdb..3aa028f 100644 (file)
@@ -1,17 +1,21 @@
 #' Compute error
 #'
-#' Obtain the errors between forecast and data
+#' Compute the errors between forecasted and measured series.
 #'
-#' @param data Dataset, object of class \code{Data} output of \code{getData}
-#' @param pred Forecast object, class \code{Forecast} output of \code{computeForecast}
-#' @param horizon Horizon where to compute the error (<= horizon used in \code{computeForecast})
+#' @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})
 #'
-#' @return A list (abs,MAPE) of lists (day,indices)
+#' @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
+#'   (absolute or MAPE) on day i. The "day" slots contain curves of errors, for each time
+#'   step, averaged on the L forecasting days.
 #'
 #' @export
 computeError = function(data, pred, horizon=data$getStdHorizon())
 {
-       L = forecast$getSize()
+       L = pred$getSize()
        mape_day = rep(0, horizon)
        abs_day = rep(0, horizon)
        mape_indices = rep(NA, L)
@@ -20,7 +24,7 @@ computeError = function(data, pred, horizon=data$getStdHorizon())
        nb_no_NA_data = 0
        for (i in seq_len(L))
        {
-               index = forecast$getIndexInData(i)
+               index = pred$getIndexInData(i)
                serie = data$getSerie(index+1)[1:horizon]
                forecast = pred$getForecast(i)[1:horizon]
                if (!any(is.na(serie)) && !any(is.na(forecast)))