projects
/
talweg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix bugs
[talweg.git]
/
pkg
/
R
/
Forecaster.R
diff --git
a/pkg/R/Forecaster.R
b/pkg/R/Forecaster.R
index
2b259fc
..
ef270b1
100644
(file)
--- a/
pkg/R/Forecaster.R
+++ b/
pkg/R/Forecaster.R
@@
-28,9
+28,8
@@
#'
#' @section Methods:
#' \describe{
#'
#' @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.}
#' \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.}
@@
-59,19
+58,19
@@
Forecaster = R6::R6Class("Forecaster",
{
# Parameters (potentially) computed during shape prediction stage
predicted_shape <- self$predictShape(data,today,memory,predict_from,horizon,...)
{
# Parameters (potentially) computed during shape prediction stage
predicted_shape <- self$predictShape(data,today,memory,predict_from,horizon,...)
- predicted_delta <-
- if (is.null(private$.pjump))
- NULL
- else
- private$.pjump(data,today,memory,predict_from,horizon,private$.params,...)
- # Predicted shape is aligned on the end of current day + jump (if jump!=NULL)
+ if (is.na(predicted_shape[1]))
+ return (NA)
+
+ 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
c( data$getSerie(today)[if (predict_from>=2) 1:(predict_from-1) else c()],
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
},
predictShape = function(data, today, memory, predict_from, horizon, ...)
NULL #empty default implementation: to implement in inherited classes