X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2FR%2FForecast.R;h=a983046198c8d7ef7d4934386f3fa26751d353ef;hb=d2ab47a744d8fb29c03a76a7ca2368dae53f9a57;hp=bcafd3a26b60d7d41713987e77c2274ed340d285;hpb=98e958cab563866f8e00886b54336018a2e8bc97;p=talweg.git diff --git a/pkg/R/Forecast.R b/pkg/R/Forecast.R index bcafd3a..a983046 100644 --- a/pkg/R/Forecast.R +++ b/pkg/R/Forecast.R @@ -1,15 +1,21 @@ #' Forecast #' -#' Forecast encapsulation +#' Forecast encapsulation as a list (days where prediction occur) of lists (components). #' -#' @docType class -#' @importFrom R6 R6Class +#' The private field .pred is a list where each cell contains the predicted variables for +#' a period of time of H<=24 hours, from hour P until P+H-1, where P == predict_from. +#' \code{forecast$getForecast(i)} output forecasts for +#' \code{data$getSerie(forecast$getIndexInData(i))}. +#' +#' @usage # Forecast$new(dates) #' -#' @field .pred List with \itemize{ -#' \item serie: forecasted serie +#' @field .pred List with +#' \itemize{ +#' \item serie: the forecasted serie #' \item params: corresponding list of parameters (weights, neighbors...) -#' \item index_in_data: corresponding index in data object} -#' @field .dates vector of day indices where forcast occurs +#' \item index_in_data: corresponding index in data object +#' } +#' @field .dates vector of (integer) day indices where forecast occurs #' #' @section Methods: #' \describe{ @@ -17,18 +23,22 @@ #' Initialize a Forecast object with a series of date indices.} #' \item{\code{getSize()}}{ #' Return number of individual forecasts.} -#' \item{\code{append(new_serie, new_params, new_index_in_data)}}{ -#' Acquire a new individual forecast, with its (optimized) parameters and the corresponding -#' index in the dataset.} +#' \item{\code{append(forecast, params, index_in_data)}}{ +#' Acquire an individual forecast, with its (optimized) parameters and the +#' corresponding index in the dataset.} #' \item{\code{getDates()}}{ #' Get dates where forecast occurs.} -#' \item{\code{getSerie(index)}}{ +#' \item{\code{getForecast(index)}}{ #' Get forecasted serie at specified index.} #' \item{\code{getParams(index)}}{ #' Get parameters at specified index (for 'Neighbors' method).} #' \item{\code{getIndexInData(index)}}{ #' Get index in data which corresponds to current forecast.} #' } +#' +#' @docType class +#' @format R6 class +#' Forecast = R6::R6Class("Forecast", private = list( .pred = list(), @@ -43,19 +53,19 @@ Forecast = R6::R6Class("Forecast", getSize = function() length(private$.pred) , - append = function(new_serie, new_params, new_index_in_data) + append = function(forecast, params, index_in_data) { private$.pred[[length(private$.pred)+1]] <- - list("serie"=new_serie, "params"=new_params, "index_in_data"=new_index_in_data) + list("forecast"=forecast, "params"=params, "index_in_data"=index_in_data) }, getDates = function() as.Date( private$.dates, origin="1970-01-01" ) , - getSerie = function(index) + getForecast = function(index) { if (is(index,"Date")) index = match(index, private$.dates) - private$.pred[[index]]$serie + private$.pred[[index]]$forecast }, getParams = function(index) {