R/TSIMD.R

Defines functions TSIMD

Documented in TSIMD

#' The TSIMD Function
#'
#' Allows Dimension Reduction of Multivariate Time Series.
#'
#' @param X Predictors.
#' @param y Target.
#' @keywords TS MV DM.
#' @export
#'
#'
#'

TSIMD <- function(X, y, n_slices = 10, n_lags = 12){
  output <- matrix(nrow = n_lags, ncol = ncol(X))
  for (i in 1:n_lags){
    # Leading the y up, removeing the relevent NA
    output[i,] <- AlgoTSIMD(X, y, n_slices = n_slices, n_lags = n_lags)
    y <- leadTSIMD(y)[-length(y)]
    X <- X[-nrow(X),]
  }
  colnames(output) <- colnames(X)
  result <- output / sum(output)
  return(result)
}
hectorhaffenden/TSIMD documentation built on Nov. 4, 2019, 1:30 p.m.