fdschneider / schneider_et_al_2016_animaldiversity

Code release for Schneider et al. 2016 'Animal diversity and ecosystem functioning in dynamic food webs'
https://www.nature.com/articles/ncomms12718
GNU General Public License v3.0
0 stars 0 forks source link

One question about nutrient supply concentration in `pdef_dynamics_2.4.c` #3

Open ZOIDG opened 8 months ago

ZOIDG commented 8 months ago

The nutrient supply concentration is saved at the *(params+2*S*S+6*S+S_b*N+i) in Line 346, but use it is not in same position at two position:

  1. When set the initial biomass densities
    • Line 382 : temp1=(double) *(params+2*S*S+5*S+2*S_b*N+i);
  2. When output data
    • Line 866 : fprintf(data1,"%.6g ",*(pparams+2*S*S+5*S+2*S_b*N+i)); // nutrient supply concentrations
ZOIDG commented 7 months ago

Sorry, because of the poor English, the expression is not clear, so comment again.

From perper we know that the nutrient supply concentration is follows a normal distribution($\mu_S=10,\sigma_S=2$).

nut_S1, nut_S2 are the initial nutrient supply concentrations,but there distribution are strange in file data/pdfe_2.4/pdef_2.4_H50_01.

The data has scatter plot: 截图 2024-03-09 17-37-32

At 3640 food web data, 400 food web the nut_S1 is 0.85, 360 food web the nut_S2 is 0.85.

So I cheak the pdef_dynamics_2.4.c file, and find the output have error in Line 866, cheak continue,find Line 382 have same error.

ZOIDG commented 7 months ago
library(ggplot2)

data <- read.table("../data/pdef_2.4/pdef_2.4_H50_01", skip = 1, header = T, sep = "")

str(data)
ggplot(data, aes(x = nut_S1)) +
    geom_histogram(binwidth = 0.01)

ggplot(data, aes(x = nut_S2)) +
    geom_histogram(binwidth = 0.01)

Rplots.pdf

fdschneider commented 7 months ago

Dear 410881, thanks for clarifying. It was difficult to see what you were looking at at first. It is indeed a strange pattern. The values for nut_S1 and nut_S2 should be within a narrow range between 0.1 and 0.2 (as they are for most cases). It is strange, that only cases with less than 30 and more than 91 animal species seem to be deviating. I would expect that only the output to the columns nut_S1 and nut_S2 is faulty, because otherwise we would have seen very irregular behaviour in the simulation output parameters.
But reviewing this is beyond my abilities, as I am not a C-programmer. The code for this project was written more than 10 years ago by a collaborator. I will need to check back with them. Best regards, Florian

fdschneider commented 7 months ago

Dear 410881, we can now confirm the assessment, that the referrence to the nutrient supply concentrations has been wrong in the two lines mentioned in the initial post. The code indexes positions in the parameter vector that are off by which contain animal body masses (variable values) or assimliation efficiencies (=0.85).

Line 866 writes the faulty values to the output data for documentation purposes only, and have not been part of the analysis further down the road. Therefore, this error has no effect on the conclusions of the paper.

The error in line 382 causes the simulations to be initiated with nutrient concentrations, i.e. the values of the two nutrient pools that are available at the very beginning of the simulations, outside the intended range.

grafik

The figure illustrates, that the intended random values for initial nutrient concentrations between 0.1 and 0.2, have only been realised for animal species richness between 32 and 90. For larger food webs, nut_S1 and nut_S2 take value 0.85 (i.e. the assimilation efficiency) and for smaller food webs they take values ranging from 0.05 to 1. Food webs with 31 and 32 animal species are even initiated with utrient concentrations values well above 5.0. This introduces a systematic bias in starting conditions along our gradient of interest, the number of animal species in the food web.

However, the initial nutrient concentrations will be very quickly amended into an equilibrium state. The simulation outcomes are only evaluated after a steady state of the food web has been achieved. We acknowledge that it may be possible that the extremely high initial nutrient concentrations cause very early extinctions of plant or animal species, or may be shifting the food web into a different attractor compared to a food web with low initial nutrient concentrations.

There is no straigtforward way to test for potential effects on the outcome of the simulations. Instead, we provide this figure showing the resulting output biomasses of plants (meanB_b) and animals (meanB_c) with initial nutrient concentrations within the correct range (black) and outside the correct range (red), each group is shown in separate plot and as an overlay plot.

grafik

We believe that this is sufficient proof, that there was no fundamentally different pattern introduced by the faulty initial parameters (red), and that the conclusions of our analysis are still valid.

Since this repository contains the simulation code for documentation purposes as a complement to the original paper, we will not update the code lines in file pdef_dynamics_2.4.c (line 382, line866). This Github issue will serve as a public documentation of the error in the simulation code.

Thank you very much for the thorough code review and for pointing the error out to us.

Best regards, Florian