R-Forge Logo

Welcome to Dynamic Time Warp project!

Comprehensive implementation of Dynamic Time Warping algorithms in R. Supports arbitrary local (eg symmetric, asymmetric, slope-limited) and global (windowing) constraints, fast native code, several plot styles, and more.

The R Package dtw provides the most complete, freely-available (GPL) implementation of Dynamic Time Warping-type (DTW) algorithms up to date.

Description

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, which is widely used e.g. for classification and clustering.

The R implementation in dtw provides:

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

In addition to computing alignments, the package provides:

Plot gallery

Go to a gallery of sample plots (straight out of the examples in the documentation).

Quickstart Example

## A noisy sine wave as query
idx<-seq(0,6.28,len=100);
query<-sin(idx)+runif(100)/10;

## A cosine is for template; sin and cos are offset by 25 samples
template<-cos(idx)

## Find the best match with the canonical recursion formula
library(dtw);
alignment<-dtw(query,template,keep=TRUE);

## Display the warping curve, i.e. the alignment curve
plot(alignment,type="threeway")

## Align and plot with the Rabiner-Juang type VI-c unsmoothed recursion
plot(
    dtw(query,template,keep=TRUE,
	step=rabinerJuangStepPattern(6,"c")),
    type="twoway",offset=-2);

## See the recursion relation, as a figure and text
plot(rabinerJuangStepPattern(6,"c"))
rabinerJuangStepPattern(6,"c")

## And much more!

Installation

To install the latest stable build of the package (hosted at CRAN), issue the following command in the R console (automated installs require R version > 2.6):
> install.packages("dtw");

To get started, begin from the installed documentation:
> library(dtw)
> ?dtw
> ?plot.dtw

You are also welcome to test the development version, hosted at R-forge (project summary page):
> install.packages("dtw",repos="http://r-forge.r-project.org")

Host-a-talk

To enjoy a personalized introduction to dtw and its applications, feel free to contact the author for an invited talk at your academic institution. Please find my e-mail address below.

Customized training and support are available for companies.

Licensing

Much effort has gone in developing this package and making it public under the GPL license. Please cite according to citation("dtw") in all publications reporting results obtained with dtw.

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

For partial matching and normalization strategies also cite:

Paolo Tormene, Toni Giorgino, Silvana Quaglini, Mario Stefanelli (2008). Matching Incomplete Time Series with Dynamic Time Warping: An Algorithm and an Application to Post-Stroke Rehabilitation. Artificial Intelligence in Medicine, 45(1), 11-34. doi:10.1016/j.artmed.2008.11.007

This software is distributed under the terms of the GNU General Public License Version 2, June 1991. The terms of this license are in a file called COPYING which you should have received with this software and which can be displayed by RShowDoc("COPYING").


Author:
Toni Giorgino at gmail.com
Computational Biochemistry and Biophysics Lab, Research Unit on Biomedical Informatics (IMIM-GRIB), Parc de Recerca Biomèdica de Barcelona (PRBB), Spain
and
Laboratory for Biomedical Informatics, University of Pavia, Italy


$Id: index.php 244 2009-09-22 14:29:40Z tonig $