knitr::opts_chunk$set(echo = TRUE)

single function effects along thresholds

Questions : - which threshold to include? - functions levels are not normally distributed. Therefore, when putting a threshold, the amount of plots passing the threshold varies per function. E.g. at threshold 0.6, most plots have high levels of N leaching but only few plots have high levels of herbivory. - --> the multifuncitonality at threshold 0.6 is probably driven by the functions with intermediate number of plots that pass the threshold. - possibly, there is a threshold where no function has a high effect - which is too "full of functions" / "lacking any functions" that anything can have an effect. We can imagine such a situation at an extremely high threshold like e.g. 0.99 : barely any plot would pass it --> so few variance that we can not explain multifuncitonality with it --> should not be included because it would only add noise.

Analysis plan

Correlate the single functions (binary, presence-absence) and multifunctionality. --> logistic regression-type correlation needed - multiple model like : multifun ~ f1{0, 1} + f2{0, 1} + f3{0, 1} + ... + f16{0, 1} - pro : do everythin in one go - functions are corrected for each other, so the correlated ones will be weaker than with just pairwise - the group of functions with many plots passing the threshold are correlated. (also the group with barley any plot passing the threshold) --> will they have very weak effects because they will be corrected for each other? - tell us which functions drive multifun for each threshold and help us interpret the results ad kind of "replace" the single functions analysis

- gives one value per function per threshold (all plots versus all plots)

Analysis

Read data

need : - single functions levels after application of threshold : is read in below - EFmaster for EFturnover at different thresholds

t01 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.1.Rds", sep = ""))
t02 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.2.Rds", sep = ""))
t03 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.3.Rds", sep = ""))
t04 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.4.Rds", sep = ""))
t05 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.5.Rds", sep = ""))
t06 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.6.Rds", sep = ""))
t07 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.7.Rds", sep = ""))
t08 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.8.Rds", sep = ""))
t09 <- readRDS(paste(pathtodata, "/data_assembly/output_data/single_functions_passing_threshold_0.9.Rds", sep = ""))

Code draft

# start with t06
d <- data.table::copy(t06)
d <- as.data.frame(d)
# calculate the turnover in single function
rownames(d) <- t06$Plotn
d <- d[, -which(names(d) %in% "Plotn")]

column_name <- "Biomass"
calc_beta_nes_and_transform <- function(d, column_name){
  beta <- BetaDivMultifun::beta.pair_zerospecies(subset(d, select = column_name))
  beta <- beta$beta.sne # take nestedness, because this is the measure defining if there is a change in the function
  beta <- as.matrix(beta)
  beta[!lower.tri(beta, diag = F)] <- NA
  beta <- reshape2::melt(beta, value.name = "test")
  beta <- beta[!is.na(beta[, 3]), ]
}
#TODO : would continue here if we wanted to do that analysis.


allanecology/multiFunBetadivLuiGDM documentation built on Nov. 12, 2023, 6:16 a.m.