Learn R Programming

⚠️There's a newer version (2.1-2) of this package.Take me there.

tclust: Robust Trimmed Clustering

The package tclust provides functions for robust trimmed clustering. The methods are described in Garcia-Escudero (2008) doi:10.1214/07-AOS515, Fritz et al. (2012) doi:10.18637/jss.v047.i12, Garcia-Escudero et al. (2011) doi:10.1007/s11222-010-9194-z and others.

Installation

The tclust package is on CRAN (The Comprehensive R Archive Network) and the latest release can be easily installed using the command

install.packages("tclust")
library(tclust)

Building from source

To install the latest stable development version from GitHub, you can pull this repository and install it using

## install.packages("remotes")
remotes::install_github("valentint/tclust", build_opts = c("--no-build-vignettes"))

Of course, if you have already installed remotes, you can skip the first line (I have commented it out).

Example

Outlying data can heavily influence standard clustering methods. At the same time, clustering principles can be useful when robustifying statistical procedures. These two reasons motivate the development of feasible robust model-based clustering approaches. Instead of trying to “fit” noisy data, a proportion α of the most outlying observations is trimmed. The tclust package efficiently handles different cluster scatter constraints. Graphical exploratory tools are also provided to help the user make sensible choices for the trimming proportion as well as the number of clusters to search for.

library(tclust)
#> Robust Trimmed Clustering (version 2.0-0)
data (M5data)
x <- M5data[, 1:2]

clus.a <- tclust (x, k = 3, alpha = 0.1, restr.fact =  1,
                  restr = "eigen", equal.weights = TRUE)
clus.b <- tclust (x, k = 3, alpha = 0.1, restr.fact =  1,
                   equal.weights = TRUE)
clus.c <- tclust (x, k = 3, alpha = 0.1, restr.fact =  1,
                  restr = "deter", equal.weights = TRUE)
clus.d <- tclust (x, k = 3, alpha = 0.1, restr.fact = 50,
                  restr = "eigen", equal.weights = FALSE)

pa <- par (mfrow = c (2, 2))
plot (clus.a, main = "(a) tkmeans")
plot (clus.b, main = "(b) Gallegos and Ritter")
plot (clus.c, main = "(c) Gallegos")
plot (clus.d, main = "(d) tclust")

par (pa)

The trimmed k-means clustering method by Cuesta-Albertos, Gordaliza and Matran (1997) optimizes the k-means criterion under trimming a portion of the points:

library(tclust)
data (swissbank)
## Two clusters and 8% trimming level
clus <- tkmeans (swissbank, k = 2, alpha = 0.08)

## Pairs plot of the clustering solution
pairs (swissbank, col = clus$cluster + 1)

                                  # Two coordinates
plot (swissbank[, 4], swissbank[, 6], col = clus$cluster + 1,
     xlab = "Distance of the inner frame to lower border",
     ylab = "Length of the diagonal")

plot (clus)

Community guidelines

Report issues and request features

If you experience any bugs or issues or if you have any suggestions for additional features, please submit an issue via the Issues tab of this repository. Please have a look at existing issues first to see if your problem or feature request has already been discussed.

Contribute to the package

If you want to contribute to the package, you can fork this repository and create a pull request after implementing the desired functionality.

Ask for help

If you need help using the package, or if you are interested in collaborations related to this project, please get in touch with the package maintainer.

Copy Link

Version

Install

install.packages('tclust')

Monthly Downloads

1,293

Version

2.0-3

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Valentin Todorov

Last Published

April 17th, 2024

Functions in tclust (2.0-3)

rlg

Robust Linear Grouping
tkmeans

TKMEANS method for robust K-means clustering
simula.tclust

Simulate contaminated data set for applying TCLUST
swissbank

Swiss banknotes data
tclust

TCLUST method for robust clustering
simula.rlg

Simulate contaminated data set for applying rlg
wholesale

Wholesale customers dataset
summary.DiscrFact

The summary method for objects of class DiscrFact
LG5data

LG5data data
plot.DiscrFact

The plot method for objects of class DiscrFact
plot.ctlcurves

The plot method for objects of class ctlcurves
ctlcurves

Classification Trimmed Likelihood Curves
DiscrFact

Discriminant Factor analysis for tclust objects
plot.tclust

Plot Method for tclust and tkmeans Objects
plot.rlg

Plot an 'rlg' object
M5data

M5data data
geyser2

Old Faithful Geyser Data
pine

Pinus nigra dataset