File: statistics-orderColnames.Rd

package info (click to toggle)
r-cran-timeseries 4041.111-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,704 kB
  • sloc: makefile: 14
file content (140 lines) | stat: -rw-r--r-- 4,249 bytes parent folder | download
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
\name{orderColnames}
\alias{orderColnames}

\alias{sortColnames}
\alias{sampleColnames}
\alias{statsColnames}
\alias{pcaColnames}
\alias{hclustColnames}


\title{Reorder column names of a time series}

\description{
    
    Functions and methods dealing with the rearrangement
    of column names of 'timeSeries' objects. 
    \cr
    
    \tabular{ll}{
    \code{orderColnames} \tab Returns ordered column names of a time Series, \cr
    \code{sortColnames} \tab Returns sorted column names of a time Series, \cr
    \code{sampleColnames} \tab Returns sampled column names of a time Series, \cr
    \code{statsColnames} \tab Returns statistically rearranged column names, \cr
    \code{pcaColnames} \tab Returns PCA correlation ordered column names, \cr
    \code{hclustColnames} \tab Returns hierarchical clustered column names. }

}

\usage{
orderColnames(x, \dots)
sortColnames(x, \dots)  
sampleColnames(x, \dots) 
statsColnames(x, FUN = colMeans, \dots)
pcaColnames(x, robust = FALSE, \dots)
hclustColnames(x, method = c("euclidean", "complete"), \dots)
}

\arguments{
        
  \item{x}{

    an object of class \code{timesSeries} or any other rectangular
    object which can be transformed by the function \code{as.matrix}
    into a numeric matrix.

  }
  \item{FUN}{ 

    a character string indicating which statistical function should be
    applied. By default statistical ordering operates on the column
    means of the time series.

  }
  \item{method}{

    a character string with two elements. The first determines the
    choice of the distance measure, see \code{\link[stats]{dist}}, and
    the second determines the choice of the agglomeration method, see
    \code{\link[stats]{hclust}}.

  }
  \item{robust}{

    a logical flag which indicates if robust correlations should be
    used.

  }

  \item{\dots}{
    
    further arguments to be passed to the underlying functions doing the
    main work, see section \sQuote{Details}.

  }
}

\details{

  These functions reorder the column names of a \code{"timeSeries"}
  object according to some statistical measure.
  

    \bold{Statistically Motivated Rearrangement} 
    
    The function \code{statsColnames} rearranges the column names
    according to a statical measure. These measure must operate on the
    columns of the time series and return a vector of values which can
    be sorted. Typical functions ar those listed in help page
    \code{colStats} but custom functions can be used that compute for
    example risk or any other statistical measure. The \code{\dots}
    argument allows to pass additional arguments to the underlying
    function \code{FUN}.
    
    \bold{PCA Ordering of the Correlation Matrix} 
    
    The function \code{pcaColnames} rearranges the column names
    according to the PCA ordered correlation matrix. The argument
    \code{robust} allsows to select between the use of the standard
    \code{cor} and computation of robust correlations using 
    the function \code{covMcd} from contributed R package
    \code{robustbase}. The \code{\dots} argument allows to pass 
    additional arguments to the two underlying functions \code{cor} 
    or \code{covMcd}. E.g., adding \code{method="kendall"} 
    to the argument list calculates Kendall's rank correlations
    instead the default which calculates Person's correlations.\cr
    
    \bold{Ordering by Hierarchical Clustering} 
    
    The function \code{pcaColnames} uses the hierarchical clustering
    approach \code{hclust} to rearrange the column names of the
    time series. 
    
}

\value{

  for \code{orderColnames}, an integer vector representing the
  permutaion that will sort the column names,

  for the other functions, a character vector giving the rearranged
  column names
        
}

\examples{
## Load Swiss Pension Fund Benchmark Data -
   data <- LPP2005REC[,1:6]
   
## Abbreviate Column Names -
   colnames(data)

## Sort Alphabetically - 
   sortColnames(data)
  
## Sort by Column Names by Hierarchical Clustering -
   hclustColnames(data)
   head(data[, hclustColnames(data)])
}

\keyword{chron}