Distance Measures

Share:

Description

Allows to measure the distance or similarity between assets.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19

Arguments

x

any rectangular time series object which can be converted by the function dist() into a distance object.

method

a character string, the method from which to compute the distances. Allowed methods include cor, kendall, spearman, mutinfo, euclidean, maximum, manhattan, canberra, binary, minkowski, braycurtis, mahalanobis, jaccard, difference, or sorensen.

nbin

an integer value, the number of bins, by default 10.

...

optional argument to be passed the distance function.

Details

corDist, kendallDist, and spearmanDist call the base cov function from R.

mutinfoDist calls the function mutinfo from the contributed R package bioDist.

euclideanDist, maximumDist, manhattanDist, canberraDist, binaryDist, and minkowskiDist are functions build on top of R's base package.

braycurtisDist, mahalanobisDist, jaccardDist, and sorensenDist call functions from the contributed R package ecodist.

Value

an object of class dist.

References

Wuertz, D., Chalabi, Y., Chen W., Ellis A. (2009); Portfolio Optimization with R/Rmetrics, Rmetrics eBook, Rmetrics Association and Finance Online, Zurich.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  
## LPP -
   # Load Swiss Pension Fund Data:
   LPP <- LPP2005REC[, 1:6]
   head(LPP)

## Returns correlation distance measure
   corDist(LPP)  
   
## Returns kendalls correlation distance measure  
   kendallDist(LPP) 
   
## Returns spearmans correlation distance measure
   spearmanDist(LPP)          

## Return mutual information distance measure
   mutinfoDist(LPP)             

## Return Euclidean distance measure
   euclideanDist(LPP)
   
## Return maximum distance measure
   maximumDist(LPP)              

## Return Manhattan distance measure  
   manhattanDist(LPP)            

## Return Canberra distance measure
   canberraDist(LPP)             

## Return binary distance measure
   binaryDist(LPP)               

## Return Minkowsky distance measure
   minkowskiDist(LPP)            

## Return Bray Curtis distance measure
   braycurtisDist(LPP)           
   
## Return Mahalanobis distance measure
   # mahalanobisDist(LPP)          
   
## Return Jaccard distance mesaure
   jaccardDist(LPP)         
   
## Return Sorensen distance measure
   sorensenDist(LPP)