Compare LOVO diagnostics across multiple distance specifications
compare_lovo_mdist.RdThis function compares **leave-one-variable-out (LOVO)** diagnostics
across multiple distance definitions supported by manydist.
Usage
compare_lovo_mdist(
x,
methods,
mds = FALSE,
dims = 2,
keep_dist = FALSE,
.progress = FALSE,
...
)Arguments
- x
A data frame or tibble containing the predictors.
- methods
A **named list** describing the distance specifications to compare. Each element must be a list of arguments passed to
lovo_mdist.For example:
- mds
Logical. If `TRUE`, compute MDS-based congruence and alienation diagnostics for every distance specification. The default is `FALSE`.
- dims
Number of dimensions used for the MDS configuration when `mds = TRUE`. Ignored when `mds = FALSE`.
- keep_dist
Logical; if
TRUE, distance matrices from the LOVO computations are retained. This increases memory usage.- .progress
Logical; if
TRUE, progress messages are printed while computing LOVO diagnostics for each method.- ...
Additional arguments passed to
lovo_mdistunless overridden in the method-specific argument list.These may include optional clustering diagnostics, for example
cluster_k,cluster_methods, andhclust_method.
Value
An object of class MDistLOVOCompare containing:
- results
A tibble with one row per method-variable combination.
- methods
The list of distance specifications used.
- mds
Whether MDS diagnostics were computed.
- dims
Number of MDS dimensions used, or `NULL` when `mds = FALSE`.
- n_obs
Number of observations in the dataset.
Details
For each distance specification, the function:
Computes the full mixed-type distance using
mdist().Recomputes the distance repeatedly leaving out one variable at a time.
Measures the impact of each variable using mean absolute deviation (MAD) and, when requested, MDS- or clustering-based diagnostics.
The results are combined across methods and returned as an
MDistLOVOCompare object, which supports
print(), summary(), and ggplot2::autoplot().
In autoplot(), reorder = TRUE ranks variables by the selected
metric averaged across methods, separately within each variable type.
Categorical variables precede numerical variables, preserving the blue/red
background bands. top_n still selects variables globally before
ordering. If type information is absent, ordering is global.
Examples
if (FALSE) { # \dontrun{
library(manydist)
library(palmerpenguins)
data <- penguins |>
dplyr::select(-species) |>
tidyr::drop_na()
cmp <- compare_lovo_mdist(
x = data,
methods = list(
gower = list(preset = "gower"),
u_dep = list(preset = "unbiased_dependent")
),
cluster_k = 3
)
summary(cmp)
autoplot(cmp, metric = "mad_importance")
autoplot(cmp, metric = "pam_importance")
} # }