Learn R Programming

dtw (version 1.15)

dtw-package: Dynamic Time Warp algorithms in R

Description

Dynamic Time Warp: find the optimal alignment between two time series.

Arguments

Details

ll{ Package: dtw Type: Package Version: 1.15 Date: 2012-8-22 License: GPL-2 }

Comprehensive implementation of Dynamic Time Warping (DTW) algorithms in R.

The basic DTW algorithm computes the time axis stretch which optimally maps one timeseries (query) onto another (reference); it outputs the remaining cumulative distance between the two. DTW is widely used e.g. for classification and clustering tasks in econometrics, chemometrics and general timeseries mining.

The R implementation in dtw provides:

  • arbitrary windowing functions (global constraints), eg. the Sakoe-Chiba band; seedtwWindowingFunctions
  • arbitrary transition types (also known as step patterns, slope constraints, local constraints, or DP-recursion rules). This includes dozens of well-known types; seestepPattern:
    • all step patterns classified by Rabiner-Juang, Sakoe-Chiba, and Rabiner-Myers;
    • symmetric and asymmetric;
    • Rabiner's smoothed variants;
    • arbitrary, user-defined slope constraints
  • partial matches: open-begin, open-end, substring matches
  • proper, pattern-dependent, normalization (exact average distance per step)
  • the Minimum Variance Matching (MVM) algorithm (Latecki et al.)

Multivariate timeseries can be aligned with arbitrary local distance definitions, leveraging the dist function of package proxy. DTW itself becomes a distance function with the dist semantics.

In addition to computing alignments, the package provides:

  • methods for plotting alignments and warping functions in several classic styles (see plot gallery);
  • graphical representation of step patterns;
  • functions for applying a warping function, either direct or inverse;
  • both fast native (C) and interpreted (R) cores.

Please see documentation for function dtw, which is the main entry point to the package.

If you use this software, please cite it according to citation("dtw"). The package home page is at http://dtw.r-forge.r-project.org.

To get the latest stable version from CRAN, use install.packages("dtw"). To get the development version (possibly unstable), use install.packages("dtw",repos="http://r-forge.r-project.org").

References

Toni Giorgino. Computing and Visualizing Dynamic Time Warping Alignments in R: The dtw Package. Journal of Statistical Software, 31(7), 1-24. http://www.jstatsoft.org/v31/i07/

Rabiner, L. R., & Juang, B.-H. (1993). Chapter 4 in Fundamentals of speech recognition. Englewood Cliffs, NJ: Prentice Hall.

See Also

dtw for the main entry point to the package; dtwWindowingFunctions for global constraints; stepPattern for local constraints; distance, outer for building a local cost matrix with multivariate timeseries and custom distance functions.

Examples

Run this code
library(dtw);
 ## demo(dtw);

Run the code above in your browser using DataLab