assess_functional_space: Assess Functional Space Quality

View source: R/assess_functional_space.R

assess_functional_spaceR Documentation

Assess Functional Space Quality

Description

Diagnostic tool to evaluate the quality of the PCoA-based functional space constructed from a trait matrix. Intended for use before running core analyses (asc_paired, asc_pairwise, etc.) to identify potential distortion from negative eigenvalues or excessive dimensionality reduction.

Usage

assess_functional_space(
  traits,
  dist_method = "gower",
  dim_retention = c("msd", "variance", "broken_stick"),
  var_tol = 0.8,
  correction = c("none", "sqrt"),
  type = NULL,
  weights = NULL
)

Arguments

traits

A data frame or matrix of functional traits.

dist_method

Distance metric for the trait matrix. Default is "gower".

dim_retention

Character. Method for choosing the number of axes: "msd" (default since 0.5.1: the number of axes, 2 to 10, whose Euclidean distances best reproduce the trait distances, i.e. the minimum mean squared deviation of Maire et al. 2015), "variance" (the axes needed to reach var_tol of the positive variance; the default up to 0.5.0) or "broken_stick" (axes that explain more variance than the broken-stick expectation).

var_tol

Numeric. Proportion of cumulative variance to retain (used when dim_retention = "variance"). Default is 0.80.

correction

Character. "none" (default) or "sqrt" (square root of the Gower dissimilarity; Euclidean for complete data, Gower 1971). Use it to compare the quality of both spaces.

type, weights

Optional; passed unchanged to daisy.

Details

All functions of the package build the same functional space: a PCoA of the distances between species traits (Gower by default), keeping the number of axes given by dim_retention. This function shows that space before any analysis, with two diagnostics:

  • Number of axes. By default ("msd") the number of axes, from 2 to 10, whose Euclidean distances best reproduce the trait distances (lowest mSD, Maire et al. 2015). The table msd shows the fidelity for each number of axes. More axes describe the traits better, but FRic can only be computed in communities with more species than axes.

  • Quality. The Gower distance is not strictly Euclidean, so the PCoA can give negative eigenvalues. The quality index is the share of positive eigenvalues; below 0.80, negative eigenvalues represent more than 20\ (traits with many missing values, redundant or badly coded traits). correction = "sqrt" (square root of the Gower dissimilarity, Euclidean for complete data with constant weights, Gower 1971) removes the negative eigenvalues, but it changes the distances between species, so results with and without it are not comparable, and its effect on the null-model tests has not been evaluated by simulation.

Value

A list of class ascent_space (it also carries the class ascfcd_space of ascent 0.5.0, which will be dropped in 0.6.0) with:

quality

Numeric. PCoA quality index (sum(positive_eig) / sum(abs(all_eig))). Values above 0.80 are generally acceptable.

n_species

Integer. Number of species in the trait matrix.

n_traits

Integer. Number of traits.

k_retained

Integer. Number of PCoA axes retained.

dim_retention

Character. Rule used to choose them.

var_retained

Numeric. Cumulative variance explained by retained axes.

axis_var

Numeric vector. Relative variance per retained axis.

n_neg_eigenvalues

Integer. Count of negative eigenvalues.

neg_eigenvalue_pct

Numeric. Percentage of total absolute eigenvalue represented by negative eigenvalues.

eigenvalues

Numeric vector. All raw eigenvalues from PCoA.

msd

Data frame. For k = 1 to 10 axes, the mean squared deviation (mSD) between the trait distances and the Euclidean distances in the first k axes (both scaled to a maximum of 1) and their Pearson correlation (Maire et al. 2015). Lower mSD = more faithful space.

References

Maire, E., Grenouillet, G., Brosse, S., & Villeger, S. (2015). How many dimensions are needed to accurately assess functional diversity? A pragmatic approach for assessing the quality of functional spaces. Global Ecology and Biogeography, 24, 728-740.

Examples

# Check the functional space before any analysis
q <- assess_functional_space(birds_sim$traits)

# Number of axes kept (rule: mSD) and quality (>= 0.8 is adequate). FRic can
# only be computed in samples with more species than retained axes.
q

# Fidelity of the space for 1 to 10 axes (lower mSD = more faithful)
summary(q)


ascent documentation built on Nov. 30, 2026, 1:07 a.m.