You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anticlustering partitions a pool of elements into clusters (or *anticlusters*) with the goal of achieving high between-cluster similarity and high within-cluster heterogeneity. This is accomplished by maximizing instead of minimizing a clustering objective function, such as the intra-cluster variance (used in k-means clustering) or the sum of pairwise distances within clusters. The package `anticlust` implements anticlustering methods as described in Papenberg and Klau (2021; https://doi.org/10.1037/met0000301), Brusco et al. (2020; https://doi.org/10.1111/bmsp.12186), Papenberg (2024; https://doi.org/10.1111/bmsp.12315), and Papenberget al. (2025; https://doi.org/10.1101/2025.03.03.641320).
12
+
Anticlustering partitions a pool of elements into clusters (or *anticlusters*) with the goal of achieving high between-cluster similarity and high within-cluster heterogeneity. This is accomplished by maximizing instead of minimizing a clustering objective function, such as the intra-cluster variance (used in k-means clustering) or the sum of pairwise distances within clusters. The package `anticlust` implements anticlustering methods as described in Papenberg and Klau (2021; https://doi.org/10.1037/met0000301), Brusco et al. (2020; https://doi.org/10.1111/bmsp.12186), Papenberg (2024; https://doi.org/10.1111/bmsp.12315), Papenberg, Wang, et al. (2025; https://doi.org/10.1016/j.crmeth.2025.101137), Papenberg, Breuer, et al. (2025; https://doi.org/10.1017/psy.2025.10052), and Yang et al. (2022; https://doi.org/10.1016/j.ejor.2022.02.003)
13
13
14
14
```{r setup, include = FALSE}
15
15
library("anticlust")
@@ -68,13 +68,13 @@ Another great way of showing your appreciation of `anticlust` is to leave a star
68
68
69
69
This README contains some basic information on the `R` package `anticlust`. More information is available via the following sources:
70
70
71
-
- Up until now, we published 3 papers describing the theoretical background of `anticlust`.
71
+
- Up until now, we published 4 papers describing the theoretical background of `anticlust`.
72
72
* The initial presentation of the `anticlust` package is given in Papenberg and Klau (2021) (https://doi.org/10.1111/bmsp.12315; [Preprint](https://doi.org/10.31234/osf.io/7jw6v)).
73
73
* The k-plus anticlustering method is described in Papenberg (2024) (https://doi.org/10.1037/met0000527; [Preprint](https://doi.org/10.31234/osf.io/dhzrc)).
74
-
* A new paper describes the must-link feature and provides additional comparisons to alternative methods, focusing on categorical variables (Papenberg et al., 2025; https://doi.org/10.1101/2025.03.03.641320).
74
+
* A new paper describes the must-link feature and provides additional comparisons to alternative methods, focusing on categorical variables (Papenberg, Wang, et al., 2025; https://doi.org/10.1016/j.crmeth.2025.101137).
75
+
* Another new paper describes several new algorithms for anticlustering and the cannot-link feature (Papenberg, Breuer, et al., 2025; https://doi.org/10.1017/psy.2025.10052).
75
76
- The R documentation of the main functions is actually quite rich and up to date, so you should definitely check that out when using the `anticlust` package. The most important background is provided in `?anticlustering`.
76
-
- A [video](https://youtu.be/YGrhSmi1oA8) is available in German language where I illustrate the main functionalities of the `anticlustering()` function. My plan is to make a similar video in English in the future.
77
-
- The [package website](https://m-py.github.io/anticlust/) contains all documentation as a convenient website. At the current time, the website also has four package vignettes, while additional vignettes are planned.
77
+
- The [package website](https://m-py.github.io/anticlust/) contains all documentation as a convenient website. Also check out the vignettes on that website.
78
78
79
79
## A quick start
80
80
@@ -89,11 +89,12 @@ Call the `anticlustering()` method:
89
89
90
90
```{r}
91
91
anticlusters <- anticlustering(
92
-
iris[, -5],
92
+
iris,
93
93
K = 5,
94
94
objective = "kplus",
95
95
method = "local-maximum",
96
-
repetitions = 10
96
+
repetitions = 10,
97
+
standardize = TRUE
97
98
)
98
99
```
99
100
@@ -115,7 +116,14 @@ Last, let's compare the features' means and standard deviations across groups to
As illustrated in the example, we can use the function `anticlustering()` to create similar groups of plants. In this case "similar" primarily means that the means and standard deviations (in parentheses) of the variables are pretty much the same across the five groups. The function `anticlustering()` takes as input a data table describing the elements that should be assigned to sets. In the data table, each row represents an element (here a plant, but it can be anything; for example a person, word, or a photo). Each column is a numeric variable describing one of the elements' features. The number of groups is specified through the argument `K`. The argument `objective` specifies how between-group similarity is quantified; the argument `method` specifies the algorithm by which this measure is optimized. See the documentation `?anticlustering` for more details.
119
+
We can also verify that the species of plants (a categorical feature) is evenly distributed among groups:
As illustrated in the example, we can use the function `anticlustering()` to create similar groups of plants. In this case "similar" primarily means that the means and standard deviations (in parentheses) of the variables are pretty much the same across the five groups, and that the species was evenly assigned to groups. The function `anticlustering()` takes as input a data table describing the elements that should be assigned to sets. In the data table, each row represents an element (here a plant, but it can be anything; for example a person, word, or a photo). Each column is a numeric variable describing one of the elements' features. The number of groups is specified through the argument `K`. The argument `objective` specifies how between-group similarity is quantified; the argument `method` specifies the algorithm by which this measure is optimized. See the documentation `?anticlustering` for more details.
119
127
120
128
Five anticlustering objectives are natively supported in `anticlustering()`:
121
129
@@ -127,27 +135,6 @@ Five anticlustering objectives are natively supported in `anticlustering()`:
127
135
128
136
The anticlustering objectives are described in detail in the documentation (`?anticlustering`, `?diversity_objective`, `?variance_objective`, `?kplus_anticlustering`, `?dispersion_objective`) and the references therein. It is also possible to optimize user-defined objectives, which is also described in the documentation (`?anticlustering`).
129
137
130
-
## Categorical variables
131
-
132
-
Sometimes, it is required that sets are not only similar with regard to
133
-
some numeric variables, but we also want to ensure that each set
134
-
contains an equal number of elements of a certain category. Coming back
135
-
to the initial iris data set, we may want to require that each set has a
136
-
balanced number of plants of the three iris species. To this end, we can
137
-
use the argument `categories` as follows:
138
-
139
-
```{r}
140
-
anticlusters <- anticlustering(
141
-
iris[, -5],
142
-
K = 3,
143
-
categories = iris$Species
144
-
)
145
-
146
-
## The species are as balanced as possible across anticlusters:
147
-
table(anticlusters, iris$Species)
148
-
149
-
```
150
-
151
138
## Matching and clustering
152
139
153
140
Anticlustering creates sets of dissimilar elements; the heterogenity within anticlusters is maximized. This is the opposite of clustering problems that strive for high within-cluster similarity and good separation between clusters. The `anticlust` package also provides functions for "classical" clustering applications: `balanced_clustering()` creates sets of elements that are similar while ensuring that clusters are of equal size. This is an example:
0 commit comments