FLXMCregbetabinom {flexord} | R Documentation |
FlexMix Driver for Regularized Beta-Binomial Mixtures
Description
This model driver can be used to cluster data using the beta-binomial distribution.
Usage
FLXMCregbetabinom(
formula = . ~ .,
size = NULL,
alpha = 0,
eps = sqrt(.Machine$double.eps)
)
Arguments
formula |
A formula which is interpreted relative to the
formula specified in the call to |
size |
Number of trials (one or more). Default |
alpha |
A non-negative scalar acting as regularization
parameter. Can be regarded as adding |
eps |
Lower threshold for the shape parameters a and b. |
Details
Using a regularization parameter alpha
greater than zero can be
viewed as adding alpha
observations equal to the population mean
to each component. This can be used to avoid degenerate solutions
(i.e., probabilites of 0 or 1). It also has the effect that
clusters become more similar to each other the larger alpha
is
chosen. For small values this effect is, however, mostly
negligible.
Value
An object of class "FLXC"
.
References
Ernst, D, Ortega Menjivar, L, Scharl, T, Grün, B (2025). Ordinal Clustering with the flex-Scheme. Austrian Journal of Statistics. Submitted manuscript.
Kondofersky, I (2008). Modellbasiertes Clustern mit der Beta-Binomialverteilung. Bachelor's thesis, Ludwig-Maximilians-Universität München.
Examples
library("flexmix")
library("flexord")
library("flexclust")
# Sample data
k <- 4 # nr of clusters
size <- 4 # nr of trials
N <- 100 # obs. per cluster
set.seed(0xdeaf)
# random probabilities per component
probs <- lapply(seq_len(k), \(ki) runif(10, 0.01, 0.99))
# sample data
dat <- lapply(probs, \(p) {
lapply(p, \(p_i) {
rbinom(N, size, p_i)
}) |> do.call(cbind, args=_)
}) |> do.call(rbind, args=_)
true_clusters <- rep(1:4, rep(N, k))
# Sample data is drawn from a binomial distribution but we fit
# beta-binomial which is a slight mis-specification but the
# beta-binomial can be seen as a generalized binomial.
m <- flexmix(dat~1, model=FLXMCregbetabinom(size=size, alpha=0),
cluster = true_clusters)
# Cluster without regularization
m1 <- stepFlexmix(dat~1, model=FLXMCregbetabinom(size=size, alpha=0), k=k)
# Cluster with regularization
m2 <- flexmix(dat~1, model=FLXMCregbetabinom(size=size, alpha=1), k=k,
cluster = posterior(m1))
# Both models are mostly able to reconstruct the true clusters (ARI ~ 0.95)
# (it's a very easy clustering problem)
# Small values for the regularization don't seem to affect the ARI (much)
randIndex(clusters(m1), true_clusters)
randIndex(clusters(m2), true_clusters)