fixes and improvements
[talweg.git] / R / getForecast.R
index c3248a9..e126946 100644 (file)
@@ -42,7 +42,7 @@ getForecast = function(data, indices, memory, horizon,
        horizon = as.integer(horizon)[1]
        if (horizon<=0 || horizon>length(data$getCenteredSerie(2)))
                stop("Horizon too short or too long")
-       indices = as.integer(indices)
+       indices = sapply( seq_along(indices), function(i) dateIndexToInteger(indices[i], data) )
        if (any(indices<=0 | indices>data$getSize()))
                stop("Indices out of range")
        indices = sapply(indices, dateIndexToInteger, data)
@@ -56,9 +56,6 @@ getForecast = function(data, indices, memory, horizon,
        pred = list()
        for (today in indices)
        {
-               #NOTE: To estimate timing...
-#              print(paste("Predict until index",today))
-
                #shape always predicted first (on centered series, no scaling taken into account),
                #with side-effect: optimize some parameters (h, weights, ...)
                predicted_shape = shape_forecaster$predict(today, memory, horizon, ...)
@@ -69,7 +66,7 @@ getForecast = function(data, indices, memory, horizon,
                #TODO: this way is faster than a call to append(); why ?
                pred[[length(pred)+1]] = list(
                        # Predict shape and align it on end of current day
-                       serie = predicted_shape + tail( data$getSerie(today), 1 ) - predicted_shape[1],
+                       serie = predicted_shape + tail( data$getSerie(today), 1 ) - predicted_shape[1] +
                                predicted_delta, #add predicted jump
                        params = shape_forecaster$getParameters(),
                        index = today )