
Compute trait-based interaction strengths and resident abundance matrix
Source:R/compute_interaction_strength.R
compute_interaction_strength.Rd
Computes a trait-based pairwise interaction matrix for all species (residents + invaders) using Gower distance (default) or another dissimilarity metric, with options for:
Kernelisation (
distance
,similarity
,gaussian
)Scaling/standardisation
Sparsification (e.g., k-nearest neighbour graph)
Also returns Nstar
, a site × resident abundance matrix from predicted values.
Usage
compute_interaction_strength(
traits,
predDF,
method = "gower",
kernel = c("distance", "similarity", "gaussian"),
sigma = NULL,
standardise = FALSE,
sparsify_k = NULL
)
Arguments
- traits
data.frame. Species traits, first column = species name, remaining = traits.
- predDF
data.frame. Long table with columns
site_id
,species
, and predicted abundance.- method
character. Distance metric for
daisy
(default"gower"
).- kernel
character. One of
"distance"
,"similarity"
,"gaussian"
.- sigma
numeric. Gaussian kernel bandwidth; if NULL, set to median non-zero distance.
- standardise
logical. If TRUE, scale distances to 0,1 before kernelisation.
- sparsify_k
integer. If non-NULL, retain only k-nearest neighbours per species (symmetrised).
Value
A list with:
g_all
: processed interaction matrix (distance or similarity).raw_distance
: unscaled Gower (or chosen) distance matrix.Nstar
: site × resident abundance matrix.sigma
: bandwidth used (if Gaussian kernel).
Details
The trait-based interaction strength matrix (g_all
) is used in community assembly
and invasion models to quantify potential biotic effects between species. We recommend
Gower distance for mixed traits, as it is scale-free and bounded in 0,1.
The resident abundance matrix (Nstar
) summarises equilibrium or expected abundances
for resident species at each site, based on predictions from the fitted abundance model.
Kernelisation options:
"distance"
: return dissimilarities directly (default for transparent interpretation)."similarity"
: convert to similarity in 0,1 by1 - scaled_distance
."gaussian"
: Gaussian kernel \(K = exp(-D^2 / (2\sigma^2))\), with automatic \(\sigma\) as the median non-zero distance if not supplied.