DBA: Dynamic Time Warping Barycenter Averaging

View source: R/DBA.R

dbaR Documentation

Dynamic Time Warping Barycenter Averaging

Description

Average multiple time series that are non-linearly aligned by Dynamic Time Warping. Find the centroid of a list of time series.

Usage

dba(lot, m0 = NULL, iterMax = 10, eps = NULL, 
                dist_method = c("norm1", "norm2", "norm2_square"),
                step_pattern = c("symmetric2", "symmetric1"),
                ws = NULL,
                iter_dist_method = c("dtw_norm1", "dtw_norm2",
                                     "norm1","norm2", "max", "min"), 
                plotit = FALSE)
                
# deprecated
DBA(lot, m0 = NULL, iterMax = 10, eps = NULL, 
                dist_method = c("norm1", "norm2", "norm2_square"),
                step_pattern = c("symmetric2", "symmetric1"),
                ws = NULL,
                iter_dist_method = c("dtw_norm1", "dtw_norm2",
                                     "norm1","norm2", "max", "min"), 
                plotit = FALSE)
                
centroid(lot, dist_method = c("norm1", "norm2", "norm2_square"),
              step_pattern = c("symmetric2", "symmetric1"),
              normalize = TRUE, ws = NULL, ncores = NULL,
              useRcppParallel = TRUE)


              
## S3 method for class 'dba'
print(x, digits = getOption("digits"),  ...)

## S3 method for class 'dba'
summary(object, ...)              

is.dba(x)             
              

Arguments

lot

List of time series. Each entry of the list is a time series as described in dtw2vec.

m0

time series as vector or matrix. If m0 is NULL, the initial time series m0 is determined by centroid as the centroid of lot, which is the one time series of lot with the minimum average DTW distance to all other time series of lot.

iterMax

integer, number of maximum iterations

eps

numeric, threshold parameter that causes the algorithm to break if the distance of two consecutive barycenters are closer than eps

dist_method

character, describes the method of distance measure. See also dtw.

step_pattern

character, describes the step pattern. See also dtw.

ws

integer, describes the window size for the sakoe chiba window. If NULL, then no window is applied. (default = NULL)

iter_dist_method

character, that describes how the distance between two consecutive barycenter iterations are defined (default = "dtw")

plotit

logical, if the iterations should be plotted or not (only possible for univariate time series)

normalize

logical, default is TRUE, passed to dtw_dismat

ncores

integer, default = NULL, passed to dtw_dismat

useRcppParallel

logical, default is TRUE, passed to dtw_dismat

x

output from dba

object

any R object

digits

passed to round and print

...

additional arguments, e.g. passed to print or summary

Details

The parameter iter_dist_method describes the method to measure the progress between two iterations. For two consecutive centroid candidates m1 and m2 the following methods are implemented:

'dtw_norm1': dtw2vec(m1, m2, dist_method = "norm1", step_pattern = "symmetric2")$normalized_distance

'idm_dtw2': dtw2vec(m1, m2, dist_method = "norm2", step_pattern = "symmetric2")$normalized_distance

'idm_norm1': sum(abs(m1-m2))/(ncol(m1) * 2 * nrow(m1))

'idm_norm2': sqrt(sum((m1-m2)^2))/(ncol(m1) * 2 * nrow(m1))

'idm_max': max(abs(m1-m2))

'idm_min': min(abs(m1-m2))

Value

call

function call

m1

new centroid/ bary center of the list of time series

iterations

list of time series that are the best centroid of the respective iteration

iterDist_m2lot

list of distances of the iterations to lot

iterDist_m2lot_norm

list of normalized distances of the iterations to lot

iterDist_m2m

vector of distances of the iterations to their ancestors

centroid_index

integer giving the index of the centroid time series of lot

dismat_result

list of results of dtw_dismat called by centroid

References

  • Leodolter, M.; Pland, C.; Brändle, N; IncDTW: An R Package for Incremental Calculation of Dynamic Time Warping. Journal of Statistical Software, 99(9), 1-23. doi: 10.18637/jss.v099.i09

  • Sakoe, H.; Chiba, S., Dynamic programming algorithm optimization for spoken word recognition, Acoustics, Speech, and Signal Processing [see also IEEE Transactions on Signal Processing], IEEE Transactions on , vol.26, no.1, pp. 43-49, Feb 1978. http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1163055

  • Petitjean, F; Ketterlin, A; Gancarski, P, A global averaging method for dynamic time warping, with applications to clustering, Pattern Recognition, Volume 44, Issue 3, 2011, Pages 678-693, ISSN 0031-3203

Examples

## Not run: 
data("drink_glass")
# initialize with any time series 
m1 <- dba(lot = drink_glass[1:10], m0 = drink_glass[[1]], 
          dist_method = "norm2", iterMax = 20)

# initialize with the centroid

tmp <- centroid(drink_glass)
cent <- drink_glass[[tmp$centroid_index]]
m1 <- dba(lot = drink_glass[1:10], m0 = cent, 
          dist_method = "norm2", iterMax = 20)

# plot all dimensions of the barycenters m_n per iteration:
plot(m1)

# plot the distances of the barycenter of one iteration m_n
# to the barycenter of the previous iteration m_n-1:
plot(m1, type = "m2m")

# plot the average distances of the barycenter m_n 
# to the list of time series:
plot(m1, type = "m2lot")


## End(Not run)

IncDTW documentation built on March 18, 2022, 6:43 p.m.