Learn R Programming

TSdist (version 3.1)

CCorDistance: Cross-correlation based distance.

Description

Computes the distance measure based on the cross-correlation between a pair of numeric time series.

Usage

CCorDistance(x, y, lag.max=(min(length(x), length(y))-1))

Arguments

x
Numeric vector containing the first time series.
y
Numeric vector containing the second time series.
lag.max
Positive integer that defines the maximum lag considered in the cross-correlation calculations (default=min(length(x), length(y))-1).

Value

  • dThe computed distance between the pair of series.

Details

The cross-correlation based distance between two numeric time series is calculated as follows: $$D= \sqrt{ ((1 - CC(x, y, 0) ^ 2) / \sum (1 - CC(x, y, k) ^ 2)) }$$ where $CC(x,y,k)$ is the cross-correlation between $x$ and $y$ at lag $k$. The summatory in the denominator goes from 1 to lag.max. In view of this, the parameter must be a positive integer no larger than the length of the series.

References

Liao, T. W. (2005). Clustering of time series data-a survey. Pattern Recognition, 38(11), 1857-1874.

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

Run this code
# The objects example.series3 and example.series4 are two 
# numeric series of length 100 and 120 contained in the 
# TSdist package. 

data(example.series3)
data(example.series4)

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

help(example.series)

# Calculate the cross-correlation based distance 
# using the default lag.max.

CCorDistance(example.series3, example.series4)

# Calculate the cross-correlaion based distance 
# with lag.max=50.

CCorDistance(example.series3, example.series4, lag.max=50)

Run the code above in your browser using DataLab