X-Git-Url: https://git.auder.net/?p=talweg.git;a=blobdiff_plain;f=pkg%2FR%2FForecaster.R;fp=pkg%2FR%2FForecaster.R;h=a10f0bd0b8f9318750963724f8141726e2a59a43;hp=784f86e48d216ee270f3ae6e775d9297ad891a8e;hb=8f5671db610e1e455b33b54986ac2e57de0da0d7;hpb=97b03431891a14666e7c481523f63d46b9ccee03 diff --git a/pkg/R/Forecaster.R b/pkg/R/Forecaster.R index 784f86e..a10f0bd 100644 --- a/pkg/R/Forecaster.R +++ b/pkg/R/Forecaster.R @@ -28,9 +28,8 @@ #' #' @section Methods: #' \describe{ -#' \item{\code{initialize(data, pjump)}}{ -#' Initialize a Forecaster object with a Data object and a jump prediction function, -#' or NULL if \code{predictShape()} returns an adjusted curve.} +#' \item{\code{initialize(pjump)}}{ +#' Initialize a Forecaster object with a jump prediction function.} #' \item{\code{predictSerie(data,today,memory,predict_from,horizon,...)}}{ #' Predict the next curve (at index today) from predict_from to horizon (hours), using #' \code{memory} days in the past.} @@ -63,19 +62,15 @@ Forecaster = R6::R6Class("Forecaster", if (is.na(predicted_shape)) return (NA) - predicted_delta <- - if (is.null(private$.pjump)) - NULL - else - private$.pjump(data,today,memory,predict_from,horizon,private$.params,...) + predicted_delta <- private$.pjump(data, today, memory, predict_from, + horizon, private$.params, first_pred=predicted_shape[1], ...) - # Predicted shape is aligned on the end of current day + jump (if jump!=NULL) + # Predicted shape is aligned on the end of current day + jump c( data$getSerie(today)[if (predict_from>=2) 1:(predict_from-1) else c()], - predicted_shape + ifelse( is.null(private$.pjump), - 0, - predicted_delta - predicted_shape[1] + - ifelse(predict_from>=2, - data$getSerie(today)[predict_from-1], tail(data$getSerie(today-1),1)) ) ) + (predicted_shape - predicted_shape[1]) + #shape with first_pred = 0 + ifelse(predict_from>=2, #last observed value + data$getSerie(today)[predict_from-1], tail(data$getSerie(today-1),1)) + + predicted_delta ) #jump }, predictShape = function(data, today, memory, predict_from, horizon, ...) NULL #empty default implementation: to implement in inherited classes