X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=R%2FS_Persistence.R;fp=R%2FS_Persistence.R;h=0000000000000000000000000000000000000000;hb=e030a6e31232332b73187eda25870e843152c174;hp=08647e31b113cd2f4c029987419551fde2ecd831;hpb=31f7d913d4a99d0a4db9bcfe40e31cebf90b22e6;p=talweg.git diff --git a/R/S_Persistence.R b/R/S_Persistence.R deleted file mode 100644 index 08647e3..0000000 --- a/R/S_Persistence.R +++ /dev/null @@ -1,34 +0,0 @@ -#' @include ShapeForecaster.R -#' -#' @title Persistence Shape Forecaster -#' -#' @description Return the last centered last (similar) day curve. -#' Inherits \code{\link{ShapeForecaster}} -PersistenceShapeForecaster = setRefClass( - Class = "PersistenceShapeForecaster", - contains = "ShapeForecaster", - - methods = list( - initialize = function(...) - { - callSuper(...) - }, - predict = function(today, memory, horizon, ...) - { - #return centered last (similar) day curve, avoiding NAs until memory is run - first_day = max(1, today-memory) - index = today-7 + 1 - repeat - { - { - last_similar_serie = data$getCenteredSerie(index)[1:horizon] - index = index - 7 - }; - if (!any(is.na(last_similar_serie))) - return (last_similar_serie); - if (index < first_day) - return (NA) - } - } - ) -)