MFdiv: Calculate Multifunctionality Divergence (MFdiv)

View source: R/MFdiv.R

MFdivR Documentation

Calculate Multifunctionality Divergence (MFdiv)

Description

Multifunctionality divergence (MFdiv) quantifies the degree of functional dispersion within an ecosystem by measuring how ecosystem functions deviate from their weighted centroid. MFdiv is calculated using a weighted mean absolute deviation approach.

Usage

MFdiv(data, weights = NULL)

Arguments

data

A data frame or matrix where rows represent observations (e.g., sites, plots) and columns represent ecosystem functions. Function values should be normalized to a common scale (e.g., 0-1).

weights

A numeric vector of weights for each function (column). If NULL, equal weights are assigned to all functions. Default is NULL.

Details

To measure MFdiv quantitatively, we employ a weighted mean absolute deviation approach.

The MFdiv is calculated as:

MFdiv = 2 \times \frac{\sum_{i=1}^{n} w_i |f_i - \mu|}{\sum_{i=1}^{n} w_i}

where:

  • f_i is the normalized performance level of function i (where f_i > 0)

  • w_i is the weight of function i

  • \mu is the weighted mean (centroid) of all function values:

\mu = \frac{\sum_{i=1}^{n} w_i f_i}{\sum_{i=1}^{n} w_i}

This metric quantifies the average weighted deviation of each function from the community's functional centroid. The multiplication by 2 scales the values to approximately [0, 1], where:

  • 0 indicates complete functional convergence (all functions perform identically)

  • Higher values represent greater functional divergence (functions are more dispersed across the performance gradient)

Only positive function values (f_i > 0) are included in the calculation. Functions with zero or negative values are automatically excluded along with their corresponding weights.

Value

A data frame with one column (MFdiv) containing the multifunctionality divergence values for each observation (row) in the input data. Row names are preserved from the input data.

Examples

# Example with sample data
data <- data.frame(
  func1 = c(0.5, 0.3, 0.2),
  func2 = c(0.2, 0.4, 0.4),
  func3 = c(0.3, 0.3, 0.4)
)
rownames(data) <- c("Site1", "Site2", "Site3")

# Calculate MFdiv with equal weights
MFdiv(data)

# Calculate MFreg with custom weights (emphasizing func2)
MFdiv(data, weights = c(1, 2, 1))



emf documentation built on Jan. 8, 2026, 5:10 p.m.

Related to MFdiv in emf...