Selecting Assets from Multivariate Asset Sets

Share:

Description

Selet assets from Multivariate Asset Sets based on clustering.

Usage

1
assetsSelect(x, method = c("hclust", "kmeans"), control = NULL, ...)

Arguments

x

any rectangular time series object which can be converted by the function as.matrix() into a matrix object, e.g. like an object of class timeSeries, data.frame, or mts.

method

a character string, which clustering method should be used? Either hclust for hierarchical clustering of dissimilarities, or kmeans for k-means clustering.

control

a character string with two entries controlling the parameters used in the underlying cluster algorithms. If set to NULL, then default settings are taken: For hierarchical clustering this is method=c(measure="euclidean", method="complete"), and for kmeans clustering this is method=c(centers=3, algorithm="Hartigan-Wong").

...

optional arguments to be passed. Note, for the k-means algorithm the number of centers has to be specified!

Details

The function assetsSelect calls the functions hclust or kmeans from R's "stats" package. hclust performs a hierarchical cluster analysis on the set of dissimilarities hclust(dist(t(x))) and kmeans performs a k-means clustering on the data matrix itself.

Note, the hierarchical clustering method has in addition a plot method.

Value

if use="hclust" was selected then the function returns a S3 object of class "hclust", otherwise if use="kmeans" was selected then the function returns an object of class "kmeans".

For details we refer to the help pages of hclust and kmeans.

Author(s)

Diethelm Wuertz for the Rmetrics port.

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
## LPP -
   # Load Swiss Pension Fund Data:
   LPP <- LPP2005REC
   colnames(LPP)
    
## assetsSelect -
   # Hierarchical Clustering:
   hclust <- assetsSelect(LPP, "hclust") 
   plot(hclust)
   
## assetsSelect -  
   # kmeans Clustering:
   assetsSelect(LPP, "kmeans", control = 
     c(centers = 3, algorithm = "Hartigan-Wong"))