X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2FR%2FF_Neighbors.R;h=143744247d5facd3a2c2cdd1a2aa27c3ea7f7e3c;hb=4e821712ee4349b08a0ab3f6bcb35a00342ddef4;hp=9af4725b45f07380ebe8cb90b600bcffd8b4a7ea;hpb=c36568faefc97bb417d355e2084398c1ad1acf92;p=talweg.git diff --git a/pkg/R/F_Neighbors.R b/pkg/R/F_Neighbors.R index 9af4725..1437442 100644 --- a/pkg/R/F_Neighbors.R +++ b/pkg/R/F_Neighbors.R @@ -28,6 +28,8 @@ #' obtain the final prediction. #' } #' +#' @usage # NeighborsForecaster$new(pjump) +#' #' @docType class #' @format R6 class, inherits Forecaster #' @aliases F_Neighbors @@ -216,31 +218,16 @@ NeighborsForecaster = R6::R6Class("NeighborsForecaster", ) ) -#' getNoNA2 -#' -#' Get indices in data of no-NA series followed by no-NA, within [first,last] range. -#' -#' @inheritParams dateIndexToInteger -#' @param first First index (included) -#' @param last Last index (included) -#' -.getNoNA2 = function(data, first, last) -{ - (first:last)[ sapply(first:last, function(i) - !any( is.na(data$getCenteredSerie(i)) | is.na(data$getCenteredSerie(i+1)) ) - ) ] -} - -#' getConstrainedNeighbs -#' -#' Get indices of neighbors of similar pollution level (among same season + day type). -#' -#' @param today Index of current day -#' @param data Object of class Data -#' @param fdays Current set of "first days" (no-NA pairs) -#' @param min_neighbs Minimum number of points in a neighborhood -#' @param max_neighbs Maximum number of points in a neighborhood -#' +# getConstrainedNeighbs +# +# Get indices of neighbors of similar pollution level (among same season + day type). +# +# @param today Index of current day +# @param data Object of class Data +# @param fdays Current set of "first days" (no-NA pairs) +# @param min_neighbs Minimum number of points in a neighborhood +# @param max_neighbs Maximum number of points in a neighborhood +# .getConstrainedNeighbs = function(today, data, fdays, min_neighbs=10, max_neighbs=12) { levelToday = data$getLevel(today) @@ -267,13 +254,13 @@ NeighborsForecaster = R6::R6Class("NeighborsForecaster", fdays } -#' compute similarities -#' -#' Apply the gaussian kernel on computed squared distances. -#' -#' @param distances2 Squared distances -#' @param window Window parameter for the kernel -#' +# compute similarities +# +# Apply the gaussian kernel on computed squared distances. +# +# @param distances2 Squared distances +# @param window Window parameter for the kernel +# .computeSimils <- function(distances2, window) { sd_dist = sd(distances2)