Function to identify groups of highly correlated variables for removing correlated features from the data for further analysis.
A hierarchical clustering of variables using hclust
is performed using
1 - the absolute correlation as a distance measure between tow variables.
corclust(x, cl = NULL, method = "complete") ## S3 method for class 'corclust' plot(x, selection = "both", mincor = NULL, ...)
x |
Either a data frame or a matrix consisting of numerical attributes. |
cl |
Optional vector of ty factor indicating class levels, if class specific correlations should to be considered. |
method |
Linkage to be used for clustering. Default is |
selection |
If |
mincor |
Adds a horizontal line for this correlation. |
... |
passed to underlying plot functions. |
Each cluster consists of a set of correlated variables according to the chosen clustering criterion.
The default criterion is ‘complete
’. This choice is meaningful as it represents the
minimum absolute correlation between all variables of a cluster.
The data set is split into numerics and factors two separate clustering models are built, depending on the variable type.
For factors distances are computed based on 1-Cramer's V statistic using chisq.test
.
For a large number of factor variables this might take some time.
The resulting trees can be plotted using plot
.
Further proceeding would consist in chosing one variable of each cluster to obtain a
subset of rather uncorrelated variables for further analysis.
An automatic variable selection can be done using cvtree
and xtractvars
.
If an additional class vector cl
is given to the function for any two variables their minimum correlation over all classes is used.
Object of class corclust
.
cor |
Correlation matrix of numeric variables. |
crv |
Matrix of Cramer's V for factor variables. |
cluster.numerics |
Resulting hierarchical |
cluster.factors |
Resulting hierarchical |
id.numerics |
Variable IDs of numeric variables in |
id.factors |
Variable IDs of factor variables |
Gero Szepannek
Roever, C. and Szepannek, G. (2005): Application of a genetic algorithm to variable selection in fuzzy clustering. In C. Weihs and W. Gaul (eds), Classification - The Ubiquitous Challenge, 674-681, Springer.
plot.corclust
and hclust
for details on the clustering algorithm, and
cvtree
, xtractvars
for postprocessing.
data(iris) classes <- iris$Species variables <- iris[,1:4] ccres <- corclust(variables, classes) plot(ccres, mincor = 0.6)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.