parInterpolate: Parallel Interpolation

View source: R/parInterpolate.R

parInterpolateR Documentation

Parallel Interpolation

Description

Function to perform interpolation on gappy series in parallel using user-specified and/or user-defined interpolation methods. Parallelization occurs over the K level.

Usage

parInterpolate(
  GappyData,
  methods = NULL,
  FUN_CALL = NULL,
  numCores = detectCores(),
  parallel = "k"
)

Arguments

GappyData

list; A list of dimension D x P x G x K containing gappy time series.

methods

character; A vector of IDs for selected interpolation methods, where m = 1,...,M

FUN_CALL

character; User-specified interpolation function(s) to be applied to GappyData. Must be a character string in the form: 'function_name(args = ..., x = '.

numCores

integer; How many CPU cores to use. The default is to use the total number of available cores, as determined by 'detectCores()'.

parallel

character; Over which index to parallelize. Possible choices: "p","g","k"

Details

Below is a list of the built-in interpolators:

  1. NN; Nearest Neighbor

  2. LI; Linear Interpolation

  3. NCS; Natural Cubic Spline

  4. FMM; Cubic Spline

  5. HCS; Hermite Cubic Spline

  6. SI; Stineman Interpolation

  7. KAF; Kalman ARIMA

  8. KSF; Kalman StructTS

  9. LOCF; Last Observation Carried Forward

  10. NOCB; Next Observation Carried Backward

  11. SMA; Simple Moving Average

  12. LWMA; Linear Weighted Moving Average

  13. EWMA; Exponential Weighted Moving Average

  14. RMEA; Replace with Mean

  15. RMED; Replace with Median

  16. RMOD; Replace with Mode

  17. RRND; Replace with Random

  18. HWI; Hybrid Wiener Interpolato

Examples

# Built-in interpolators
methods <- c(17,5) # Replace with Random, Hermite Cubic Spline

# User-defined functions to pass to FUN_CALL
## Toy function 1: Convert each value of x to its index position
plus <- function(x){
vec <- numeric(length(x))
for(i in 1:length(vec)){
 vec[i] <- i
}
return(vec)
}

## Toy function 2: Convert each value of x to its negative index position
minus <- function(x){
 vec <- numeric(length(x))
 for(i in 1:length(vec)){
   vec[i] <- -i
 }
 return(vec)
}

FUN_CALL <- c("plus(","minus(")

# Interpolation

 IntData <- parInterpolate(GappyData = GappyData, methods = methods, FUN_CALL = FUN_CALL)
 
 # dimension D x M x P x G x K 
 

castels/interpTools documentation built on June 7, 2024, 4:20 p.m.