关于R包adespatial的beta.div.comp与betapart的beta.multi计算结果差异的技术问询
adespatial::beta.div.comp(coef="BJ") and betapart::beta.multi(index.family="jaccard") return different results? Hey there, great catch on this discrepancy! The different outputs from these two functions aren't due to code bugs—they come down to two fundamentally different ways of calculating and summarizing beta diversity under Baselga's decomposition framework. Let me break this down clearly:
1. Core Difference: Pairwise Averaging vs. Global Summary
adespatial::beta.div.comp(coef="BJ")
This function takes a "pairwise-first" approach:
- It calculates the Jaccard dissimilarity (and its turnover/nestedness components) for every single pair of sites in your matrix.
- It then averages all those pairwise values, and divides by 2 (since the distance matrix includes each pair twice, and
sum(D)/(n*(n-1))is equivalent tomean(D)/2). - The result you get is the average pairwise beta diversity across all site pairs, split into turnover and nestedness.
As you already verified, you can replicate its outputs directly with betapart's pairwise function:
pair_res <- beta.pair(A, index.family = "jaccard") # Matches beta.div.comp$part$BDtotal mean(pair_res$beta.jac) / 2 # Matches beta.div.comp$part$Repl mean(pair_res$beta.jtu) / 2 # Matches beta.div.comp$part$Nes mean(pair_res$beta.jne) / 2
betapart::beta.multi(index.family="jaccard")
This function takes a "global-first" approach:
- It first computes summary statistics across the entire community matrix—like total species richness in the region, sum of site-level richness, total shared species across all sites, and aggregated counts of species gains/losses.
- It plugs these global stats directly into Baselga's formulas for beta diversity decomposition, producing a single value that represents beta diversity at the whole-community scale, not an average of pairwise differences.
2. What This Means For Your Analysis
Neither approach is "wrong"—they answer different research questions:
- Use
beta.div.compif you want to describe the average degree of differentiation between individual site pairs (e.g., "On average, any two sites share X% of their species"). - Use
beta.multiif you want to describe how much the entire community deviates from the regional species pool (e.g., "Across all sites, only Y% of the regional species are present in any single site").
3. Quick Validation of the Relationship
To confirm this, run both calculations side-by-side with your test data:
# adespatial's average pairwise total beta mean(beta.pair(A, index.family = "jaccard")$beta.jac) / 2 # Output: 0.3258676 (matches beta.div.comp$part$BDtotal) # betapart's global total beta beta.multi(A, index.family="jaccard")$beta.JAC # Output: 0.9356033 (global community-scale beta)
The gap between these numbers is exactly the difference between averaging pairwise dissimilarities and calculating a single global dissimilarity metric.
内容的提问来源于stack exchange,提问作者Manuel Popp

