View source: R/parInterpolate.R
parInterpolate | R Documentation |
Function to perform interpolation on gappy series in parallel using user-specified and/or user-defined interpolation methods. Parallelization occurs over the K level.
parInterpolate(
GappyData,
methods = NULL,
FUN_CALL = NULL,
numCores = detectCores(),
parallel = "k"
)
GappyData |
|
methods |
|
FUN_CALL |
|
numCores |
|
parallel |
|
Below is a list of the built-in interpolators:
NN
; Nearest Neighbor
LI
; Linear Interpolation
NCS
; Natural Cubic Spline
FMM
; Cubic Spline
HCS
; Hermite Cubic Spline
SI
; Stineman Interpolation
KAF
; Kalman ARIMA
KSF
; Kalman StructTS
LOCF
; Last Observation Carried Forward
NOCB
; Next Observation Carried Backward
SMA
; Simple Moving Average
LWMA
; Linear Weighted Moving Average
EWMA
; Exponential Weighted Moving Average
RMEA
; Replace with Mean
RMED
; Replace with Median
RMOD
; Replace with Mode
RRND
; Replace with Random
HWI
; Hybrid Wiener Interpolato
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.