Fits archetypal analysis models, including Euclidean,
probabilistic, kernel, and directional variants. Methods include classical
archetypal analysis from Cutler and Breiman (1994)
yaap is Yet Another Archetypes Package: a practical, matrix-first R
toolkit that brings together many variants and flavors of archetypal analysis
in one place. Some of these workflows are currently scattered across different
packages, while others have had little or no R implementation available.
The package centers on a shared run_aa() interface for fitting, inspecting,
comparing, plotting, and reusing archetypal analysis models. It supports
multivariate, functional, non-Gaussian, kernel, and directional AA, plus direct
solver wrappers when you want more control.
yaap is currently under revision and may not yet be available on CRAN. For
now, install the development version from GitHub:
# install.packages("pak")
pak::pak("teosakel/yaap")
Once released on CRAN, installation will be:
install.packages("yaap")
The core workflow is matrix-based: rows are samples, columns are features, and archetypes are fitted as extreme profiles in the convex hull of the data.
library(yaap)
X <- as.matrix(iris[, 1:4]) # numeric columns
fit <- run_aa(X, K = 3, nrep = 5, scale = TRUE)
coordinates(fit) # K x features: the archetype profiles
compositions(fit)[1:6, ] # samples x K: each sample's archetype mixture
plot(fit, what = "profiles")
generics::glance(fit)
You can also fit by formula when that is more convenient:
fit_iris <- run_aa(Species ~ ., data = iris, K = 3, scale = TRUE)
yaap Do? 🧰run_aa(..., method = "pgd"), run_aa(..., method = "nnls"),
archetypes_pgd(), and archetypes_nnls().run_aa(..., method = "paa", family = ...).run_aa(..., method = "kernel", kernel = ...), including precomputed kernels.run_aa(..., method = "directional").scale = G and
direct support for fda::fd objects.NA values are present.aa_init(), including random,
Dirichlet, furthest-first, k-means++, FurthestSum, AA++, batched coreset-style
initialization, and hull-outmost strategies.archetypes_path(),
screeplot(), AIC(), loss tracking, plotting methods, and standard S3
helpers such as predict(), fitted(), and residuals().generics::tidy(), generics::glance(),
generics::augment(), and the recipes step step_archetypes().The README is only the map. The vignettes are the snacks.
run_aa() workflow,
object structure, plotting, prediction, choosing K, robust fitting, missing
data, and PGD vs NNLS.aa_init() works, when
initialization matters, and how FurthestSum, AA++, batched, and hull-based methods behave.step_archetypes() inside
recipes workflows and tuning archetype-related parameters.yaap keeps the references close to the features they support: