View source: R/3_5DTWBI_algorithm_simple_univariate.R
| DTWBI_univariate | R Documentation |
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.
DTWBI_univariate(
data,
t_gap,
T_gap,
DTW_method = "DTW",
threshold_cos = NULL,
step_threshold = NULL,
thresh_cos_stop = 0.8,
...
)
data |
input vector containing a large and continuous gap (eventually derived from local.derivative.ddtw() function) |
t_gap |
location of the beginning 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 |
A list containing the following elements:
output_vector |
Complete data including the imputation proposal |
input_vector |
Original input vector |
query |
Sequence adjacent to the gap used as the query. |
pos_query |
Indices of the beginning and end of the query. |
sim_window |
Values of the sequence most similar to the query. |
pos_sim_window |
Indices of the beginning and end of the similar window. |
imputation_window |
Imputed values. |
pos_imp_window |
Indices of the beginning and end of the imputation window. |
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.