MF2_multiple: multifunctionality measures for multiple ecosystems

MF2_multipleR Documentation

multifunctionality measures for multiple ecosystems

Description

MF2_multiple computes alpha, beta and gamma multifuctionality measures of orders q = 0, 1 and 2 for given function weights in multiple ecosystems separately for two cases (i) correlations between functions are not corrected for, and (ii) correlations between functions are corrected for. Species alpha, beta and gamma diversity of orders q = 0, 1, and 2 will also be computed if species abundance data are provided.

Usage

MF2_multiple(
  func_data,
  species_data = NULL,
  weight = 1,
  q = c(0, 1, 2),
  by_group = NULL,
  by_pair = TRUE
)

Arguments

func_data

ecosystem function data should be input as a data.frame (ecosystems by functions for multiple ecosystems). All function values must be normalized between 0 and 1.
For by_group = NULL, the func_data must contain only the ecosystem function columns. (e.g., those columns specified in the argument fun_cols if user use function_normalization to do normalization). If by_group is not NULL,in addition to ecosystem function columns, the by_group column must be included.
The row names of func_data should be set the same as the names of plotID specified in species_data if species_data is not NULL.

species_data

species abundance data should be input as a data.frame and must include three columns: "plotID", "species" and "abundance". Default is NULL. If by_group is not NULL and species_data is not NULL,in addition to the three columns mentioned earlier, the by_group column must be included.

weight

a constant number (if all weights are equal) or a numerical vector specifying weights for ecosystem functions. In the latter case, the length of weight must be equal to the number of functions. Default is weight = 1, which means equal weight and weight = 1 for all ecosystem functions.

q

a numerical vector specifying the multifunctionality and diversity orders. Default is q = 0, 1 and 2.

by_group

the column name of the stratifying variable that is used to group data for performing decomposition. For example, if by_group = "country" and by_pair = TRUE, then multifunctionality decomposition is performed for any pair of plots selected within a country.
The by_group setting must be the same as that set in function_normalization. Default is NULL.

by_pair

a logical variable specifying whether to perform multifunctionality decomposition for all pairs of ecosystems or not. If by_pair = TRUE, alpha/beta/gamma multifunctionality will be computed for all pairs of ecosystems/plots in the input data; if by_pair = FALSE, alpha/beta/gamma multifunctionality will be computed for multiple ecosystems (i.e, more than two ecosystems) in the input data. Default is TRUE.

Value

a data.frame with columns "plotID" (combinations of plot pairs, if calculating not by pairs, then there is no such column), "Order.q" , "Type" (corr_uncorrected or corr_corrected) , "Scale" (gamma, alpha or beta) and "qMF" (multifunctionality of order q). When by_group is not NULL (i.e., the column name of the stratifying variable is specified), an additional column with stratification variable (e.g., "country" of the plot pairs) is also shown after the plotID column. For species_data is not NULL, the data.frame will show an additional column contain "Species.diversity" in the last column.

Examples


library(dplyr)


### Use data from plots in five countries (data in Finland are excluded) to decompose MF 
### for all pairs of plots

data("forest_function_data_normalized")
data("forest_biodiversity_data")
forest_function_data_normalized <- filter(forest_function_data_normalized, country != "FIN")
forest_biodiversity_data <- forest_biodiversity_data[-(1:48),]

MF2_multiple(func_data = forest_function_data_normalized[,6:32],
             species_data = forest_biodiversity_data,
             weight = 1,
             by_group = "country")
             

### Use partial data to quickly obtain output 
### (Take the first 18 plots in Germany and the last 18 plots in Italy)
### BF decomposition for all pairs of plots

data("forest_function_data_raw")
data("forest_biodiversity_data")
GER_ITA_forest_function_raw <- filter(forest_function_data_raw, 
                                      country=="GER"|country=="ITA")[c(1:18,57:74),]
GER_ITA_forest_function_normalized <- function_normalization(data = GER_ITA_forest_function_raw,
                                                             fun_cols = 6:31, 
                                                             negative = c("soil_cn_ff_10","wue"),
                                                             by_group = "country")
GER_ITA_forest_biodiversity <- forest_biodiversity_data[c(49:82,181:229),]

MF2_multiple(func_data = GER_ITA_forest_function_normalized[,6:32],
             species_data = GER_ITA_forest_biodiversity,
             weight = 1,
             by_group = "country")



### Use partial data to decompose multifunctionality based on 3 plots in each country, not by pairs 
### (Take the first 3 plots in each country)              
             
data("forest_function_data_raw")
data("forest_biodiversity_data")

forest_function_data_raw_3plots <- forest_function_data_raw[c(1:3,29:31,67:69,103:105,
                                                                      146:148,174:176),]
forest_function_data_normalized_3plots <- 
                    function_normalization(data = forest_function_data_raw_3plots,
                                           fun_cols = 6:31, 
                                           negative = c("soil_cn_ff_10","wue"),
                                           by_group = "country")
forest_biodiversity_data_3plots <- 
                   forest_biodiversity_data[c(1:6,49:52,141:148,230:232,351:355,411:417),]

MF2_multiple(func_data = forest_function_data_normalized_3plots[,6:32],
             species_data = forest_biodiversity_data_3plots,
             weight = 1,
             by_group = "country", by_pair = FALSE)



MF.beta4 documentation built on Nov. 3, 2024, 5:06 p.m.