Learn R Programming

TSdist (version 2.2)

tsDistances: TSdist distance computation.

Description

TSdist distance calculation between two time series.

Usage

tsDistances(x, y, tx, ty, distance, ...)

Arguments

x
Numeric vector or ts, zoo or xts object containing the first time series.
y
Numeric vector or ts, zoo or xts object containing the second time series.
tx
Optional temporal index of series x. Only necessary if x is a numeric vector and the sampling index is not constant.
ty
Optional temporal index of series y. Only necessary if y is a numeric vector and the sampling index is not constant.
distance
Distance measure to be used. It must be one of: "euclidean", "manhattan", "minkowski", "infnorm", "ccor", "sts", "dtw", "keogh_lb", "edr",
...
Additional parameters required by the distance method.

Value

  • dThe computed distance between the pair of time series.

Details

The distance between the two time series x and y is calculated. x and y can be saved in a numeric vector or a ts, zoo or xts object. The following distance methods are supported:

Some distance measures may require additional arguments. See the individual help pages (detailed above) for more information about each method.

Examples

Run this code
#The objects zoo.series1 and zoo.series2 are two 
#zoo objects that save two series of length 100. 

data(zoo.series1)
data(zoo.series2)

#For information on their generation and shape see 
#help page of example.series.

help(example.series)

#The distance calculation for these two series is done
#as follows:

tsDistances(zoo.series1, zoo.series2, distance="infnorm")
tsDistances(zoo.series1, zoo.series2, distance="cor", beta=3)
tsDistances(zoo.series1, zoo.series2, distance="dtw", sigma=20)

Run the code above in your browser using DataLab