dtwclust-package: Time series clustering along with optimizations for the...

dtwclust-packageR Documentation

Time series clustering along with optimizations for the Dynamic Time Warping distance


Time series clustering with a wide variety of strategies and a series of optimizations specific to the Dynamic Time Warping (DTW) distance and its corresponding lower bounds (LBs).


Many of the algorithms implemented in this package are specifically tailored to DTW, hence its name. However, the main clustering function is flexible so that one can test many different clustering approaches, using either the time series directly, or by applying suitable transformations and then clustering in the resulting space. Other implementations included in the package provide some alternatives to DTW.

DTW is a dynamic programming algorithm that tries to find the optimum warping path between two series. Over the years, several variations have appeared in order to make the procedure faster or more efficient. Please refer to the included references for more information, especially Giorgino (2009), which is a good practical introduction.

Most optimizations require equal dimensionality, which means time series should have equal length. DTW itself does not require this, but it is relatively expensive to compute. Other distance definitions may be used, or series could be reinterpolated to a matching length (Ratanamahatana and Keogh 2004).

The main clustering function and entry point for this package is tsclust(), with a convenience wrapper for multiple tests in compare_clusterings(), and a shiny app in interactive_clustering(). There is another less-general-purpose shiny app in ssdtwclust().

Please note the random number generator is set to L'Ecuyer-CMRG when dtwclust is attached in an attempt to preserve reproducibility. You are free to change this afterwards if you wish (see base::RNGkind()), but dtwclust will always use L'Ecuyer-CMRG internally.

For more information, please read the included package vignettes, which can be accessed by typing browseVignettes("dtwclust").


This software package was developed independently of any organization or institution that is or has been associated with the author.

This package can be used without attaching it with base::library() with some caveats:

  • The methods package must be attached. R usually does this automatically, but utils::Rscript() only does so in R versions 3.5.0 and above.

  • If you want to use the proxy version of dtw::dtw() (e.g. for clustering), you have to attach the dtw package manually.

Be careful with reproducibility, R's random number generator is only changed session-wide if dtwclust is attached.


Alexis Sarda-Espinosa


Please refer to the package's vignette's references.

See Also

tsclust(), compare_clusterings(), interactive_clustering(), ssdtwclust(), dtw_basic(), proxy::dist().

dtwclust documentation built on March 7, 2023, 7:49 p.m.