cluster.varstats {fpc} | R Documentation |
Variablewise statistics for clusters
Description
This function gives some helpful variable-wise information for cluster interpretation, given a clustering and a data set. The output object contains some tables. For categorical variables, tables compare clusterwise distributions with overall distributions. Continuous variables are categorised for this.
If desired, tables, histograms, some standard statistics of
continuous variables and validation plots as available through
discrproj
(Hennig 2004) are given out on the fly.
Usage
cluster.varstats(clustering,vardata,contdata=vardata,
clusterwise=TRUE,
tablevar=NULL,catvar=NULL,
quantvar=NULL, catvarcats=10,
proportions=FALSE,
projmethod="none",minsize=ncol(contdata)+2,
ask=TRUE,rangefactor=1)
## S3 method for class 'varwisetables'
print(x,digits=3,...)
Arguments
clustering |
vector of integers. Clustering (needs to be in standard coding, 1,2,...). |
vardata |
data matrix or data frame of which variables are summarised. |
contdata |
variable matrix or data frame, normally all or some
variables from |
clusterwise |
logical. If |
tablevar |
vector of integers. Numbers of variables treated as
categorical (i.e., no histograms and statistics, just tables) if
|
catvar |
vector of integers. Numbers of variables to be categorised by proportional quantiles for table computation. Recommended for all continuous variables. |
quantvar |
vector of integers. Variables for which means,
standard deviations and quantiles should be given out if
|
catvarcats |
integer. Number of categories used for
categorisation of variables specified in |
proportions |
logical. If |
projmethod |
one of |
minsize |
integer. Projection is not carried out for clusters with fewer points than this. (If this is chosen smaller, it may lead to errors with some projection methods.) |
ask |
logical. If |
rangefactor |
numeric. Factor by which to multiply the range for projection plot ranges. |
x |
an object of class |
digits |
integer. Number of digits after the decimal point to print out. |
... |
not used. |
Value
An object of class "varwisetables"
, which is a
list with a table for each variable, giving (categorised) marginal
distributions by cluster.
Author(s)
Christian Hennig christian.hennig@unibo.it https://www.unibo.it/sitoweb/christian.hennig/en
References
Hennig, C. (2004) Asymmetric linear dimension reduction for classification. Journal of Computational and Graphical Statistics 13, 930-945 .
Examples
set.seed(112233)
options(digits=3)
require(MASS)
require(flexmix)
data(Cars93)
Cars934 <- Cars93[,c(3,5,8,10)]
cc <-
discrete.recode(Cars934,xvarsorted=FALSE,continuous=c(2,3),discrete=c(1,4))
fcc <- flexmix(cc$data~1,k=2,
model=lcmixed(continuous=2,discrete=2,ppdim=c(6,3),diagonal=TRUE))
cv <-
cluster.varstats(fcc@cluster,Cars934, contdata=Cars934[,c(2,3)],
tablevar=c(1,4),catvar=c(2,3),quantvar=c(2,3),projmethod="awc",
ask=FALSE)
print(cv)