STSDistance: Short time series distance (STS).

View source: R/sts_distance.R

STSDistanceR Documentation

Short time series distance (STS).

Description

Computes the Short Time Series Distance between a pair of numeric time series.

Usage

STSDistance(x, y, tx, ty)

Arguments

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 x.

ty

If not constant, a numeric vector that specifies the sampling index of series y.

Details

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

Value

d

The computed distance between the pair of series.

Author(s)

Usue Mori, Alexander Mendiburu, Jose A. Lozano.

References

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.

See Also

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.

Examples

# 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)




TSdist documentation built on Aug. 31, 2022, 5:09 p.m.