Learn R Programming

TSdist (version 1.1)

correlationDistance: Pearson correlation based distance.

Description

Computes two different distance measures based on Pearson's correlation between a pair of numeric time series.

Usage

correlationDistance(x, y, beta)

Arguments

x
Numeric vector containing the first time series.
y
Numeric vector containing the second time series.
beta
Positive parameter. If defined, the second Pearson correlation based distance measure will be computed.

Value

  • dThe computed distance between the pair of series.

Details

Two different distances based on Pearson's correlation are calculated between two numeric time series. The series must be of the same length.

If beta is not specified the distance is calculated as follows:

$$D1=2 (1 - Cor(x, y))$$ If beta is specified, it must be positive and, the following formula is used to compute the distance:

$$D2=( (1 - Cor(x, y)) / (1 + Cor(x, y)) ) ^ \beta$$ where $Cor(x,y)$ is Pearson's correlation between $x$ and $y$.

References

Golay, X., Kollias, S., Stoll, G., Meier, D., Valavanis, A., and Boesiger, P. (2005) A new correlation-based fuzzy logic clustering algorithm for FMRI. Magnetic Resonance in Medicine, 40(2), 249--260.

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.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 Pearson correlation based distance using the first method

correlationDistance(example.series1, example.series2)

#Calculate the Pearson correlation based distance using the second method 
#with beta=3.

correlationDistance(example.series1, example.series2, beta=3)

Run the code above in your browser using DataLab