X-Git-Url: https://git.auder.net/images/pieces/%22%20%20%20VariantRules.getPpath%28board%5Bi%5D%5Bj%5D%29%20%20%20%22.svg?a=blobdiff_plain;f=R%2FF_Persistence.R;h=fa5f99f5373b735b63f4618768f0b6eebab9694f;hb=HEAD;hp=19cf2e410e3e255ddabcc57326321cc1ef510679;hpb=e5aa669afc0b71278d1a864fb0d4e2aff8032ef1;p=talweg.git diff --git a/R/F_Persistence.R b/R/F_Persistence.R deleted file mode 100644 index 19cf2e4..0000000 --- a/R/F_Persistence.R +++ /dev/null @@ -1,36 +0,0 @@ -#' @include Forecaster.R -#' -#' @title Persistence Forecaster -#' -#' @description Return the last centered (similar) day curve. -#' Inherits \code{\link{Forecaster}} -PersistenceForecaster = setRefClass( - Class = "PersistenceForecaster", - contains = "Forecaster", - - methods = list( - initialize = function(...) - { - callSuper(...) - }, - predictShape = function(today, memory, horizon, ...) - { - # Return centered last (similar) day curve, avoiding NAs until memory is run - first_day = max(1, today-memory) - same_day = ifelse(hasArg("same_day"), list(...)$same_day, TRUE) - # If 'same_day', get the last known future of similar day: -7 + 1 == -6 - index = today - ifelse(same_day,6,0) - repeat - { - { - last_serie = data$getCenteredSerie(index)[1:horizon] - index = index - ifelse(same_day,7,1) - }; - if (!any(is.na(last_serie))) - return (last_serie); - if (index < first_day) - return (NA) - } - } - ) -)