DTWBI_univariate {DTWBI} | R Documentation |
DTWBI algorithm for univariate signals
Description
Imputes values of a gap of position t_gap and size T in a univariate signal based on DTW algorithm. For more details on the method, see Phan et al. (2017) DOI: <10.1016/j.patrec.2017.08.019>. Default arguments of dtw() function are used but can be manually explicited and modified.
Usage
DTWBI_univariate(data, t_gap, T_gap, DTW_method = "DTW",
threshold_cos = NULL, step_threshold = NULL, thresh_cos_stop = 0.8, ...)
Arguments
data |
input vector containing a large and continuous gap (eventually derived from local.derivative.ddtw() function) |
t_gap |
location of the begining of the gap (eventually extracted from gapCreation function) |
T_gap |
gap size (eventually extracted from gapCreation function) |
DTW_method |
DTW method used for imputation ("DTW", "DDTW", "AFBDTW"). By default "DTW". |
threshold_cos |
threshold used to define similar sequences to the query. By default, threshold_cos=0.9995 if sequence is longer than 10'000, and threshold_cos=0.995 if shorter. |
step_threshold |
step used within the loop determining the threshold. By default, step_threshold=50 if sequence is longer than 10'000, step_threshold=10 if sequence length is between 1'000 and 10'000. Else, step_threshold=2. |
thresh_cos_stop |
Define the lowest cosine threshold acceptable to find a similar window to the query. By default, thresh_cos_stop=0.8. |
... |
additional arguments from the dtw() function |
Value
DTWBI_univariate returns a list containing the following elements:
output_vector: output vector containing complete data including the imputation proposal
input_vector: original vector used as input
query: the query i.e. the adjacent sequence to the gap
pos_query: index of the begining and end of the query
sim_window: vector containing the values of the most similar sequence to the query
pos_sim_window: index of the begining and end of the similar window
imputation_window: vector containing imputed values
pos_imp_window: index of the begining and end of the imputation window
Author(s)
Camille Dezecache, Hong T. T. Phan, Emilie Poisson-Caillault
Examples
data(dataDTWBI)
X <- dataDTWBI[, 1]
rate <- 0.1
output <- gapCreation(X, rate)
data <- output$output_vector
gap_begin <- output$begin_gap
gap_size <- output$gap_size
imputed_data <- DTWBI_univariate(data, t_gap=gap_begin, T_gap=gap_size)
plot(imputed_data$input_vector, type = "l", lwd = 2) # Uncomplete signal
lines(imputed_data$output_vector, col = "red") # Imputed signal
lines(y = imputed_data$query,
x = imputed_data$pos_query[1]:imputed_data$pos_query[2],
col = "green", lwd = 4) # Query
lines(y = imputed_data$sim_window,
x = imputed_data$pos_sim_window[1]:imputed_data$pos_sim_window[2],
col = "orange", lwd = 4) # Similar sequence to the query
lines(y = imputed_data$imputation_window,
x = imputed_data$pos_imp_window[1]:imputed_data$pos_imp_window[2],
col = "blue", lwd = 4) # Imputing proposal