File: assets-selection.Rd

package info (click to toggle)
fassets 3011.83-2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 428 kB
  • sloc: makefile: 1
file content (111 lines) | stat: -rw-r--r-- 2,734 bytes parent folder | download | duplicates (3)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
\name{assets-selection}


\alias{assetsSelect}


\title{Selecting Assets from Multivariate Asset Sets}


\description{
  
    Selet assets from Multivariate Asset Sets based 
    on clustering.
    
}
    

\usage{
assetsSelect(x, method = c("hclust", "kmeans"), control = NULL, \dots)
}


\arguments{
  
    \item{x}{
        any rectangular time series object which can be converted by the 
        function \code{as.matrix()} into a matrix object, e.g. like an 
        object of class \code{timeSeries}, \code{data.frame}, or \code{mts}. 
        } 
    \item{method}{
        a character string, which clustering method should be used? 
        Either \code{hclust} for hierarchical clustering of dissimilarities,
        or \code{kmeans} for k-means clustering.
        }
    \item{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 
        \code{method=c(measure="euclidean", method="complete")}, 
        and for kmeans clustering this is
        \code{method=c(centers=3, algorithm="Hartigan-Wong")}.
        }
    \item{\dots}{
        optional arguments to be passed. Note, for the k-means algorithm
        the number of centers has to be specified!
        }
        
}


\value{
  
    if \code{use="hclust"} was selected then the function returns a
    S3 object of class "hclust", otherwise if \code{use="kmeans"} was 
    selected then the function returns an object of class "kmeans". 
    
    For details we refer to the help pages of \code{hclust} and 
    \code{kmeans}.
    
}


\details{
      
    The function \code{assetsSelect} calls the functions \code{hclust}
    or \code{kmeans} from R's \code{"stats"} package. \code{hclust}
    performs a hierarchical cluster analysis on the set of dissimilarities 
    \code{hclust(dist(t(x)))} and \code{kmeans} performs a k-means
    clustering on the data matrix itself. 
    
    Note, the hierarchical clustering method has in addition a plot method.
    
}


\author{

    Diethelm Wuertz for the Rmetrics port.
    
}


\references{

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


\examples{
## 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"))
}


\keyword{models}