STSDistance | R Documentation |
Computes the Short Time Series Distance between a pair of numeric time series.
STSDistance(x, y, tx, ty)
x |
Numeric vector containing the first time series. |
y |
Numeric vector containing the second time series. |
tx |
If not constant, a numeric vector that specifies the sampling index of series |
ty |
If not constant, a numeric vector that specifies the sampling index of series |
The short time series distance between two series is designed specially for series with an equal but uneven sampling rate. However, it can also be used for time series with a constant sampling rate. It is calculated as follows:
STS= √{∑_{k=\{1,...,N-1\}} (((y_{k+1} - y_{k}) / (tx_{k+1} - tx_{k}) - (x_{k+1} - x_{k}) / (ty_{k+1} - ty_{k}))^2)}
where N is the length of series x and y.
tx
and ty
must be positive and strictly increasing. Furthermore, the sampling rate in both indexes must be equal:
tx[k+1]-tx[k]=ty[k+1]-ty[k], \, \, \, for \, \, \, k=0 ,..., N-1
d |
The computed distance between the pair of series. |
Usue Mori, Alexander Mendiburu, Jose A. Lozano.
Möller-Levet, C. S., Klawonn, F., Cho, K., & Wolkenhauer, O. (2003). Fuzzy Clustering of Short Time-Series and Unevenly Distributed Sampling Points. In Proceedings of the 5th International Symposium on Intelligent Data Analysis.
To calculate this distance measure using ts
, zoo
or xts
objects see TSDistances
. To calculate distance matrices of time series databases using this measure see TSDatabaseDistances
.
# The objects example.series1 and example.series2 are two # numeric series of length 100 contained in the TSdist package. data(example.series1) data(example.series2) # For information on their generation and shape see help # page of example.series. help(example.series) # Calculate the STS distance assuming even sampling: STSDistance(example.series1, example.series2) # Calculate the STS distance providing an uneven sampling: tx<-unique(c(seq(2, 175, 2), seq(7, 175, 7))) tx <- tx[order(tx)] ty <- tx STSDistance(example.series1, example.series2, tx, ty)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.