"A Bayesian optimal escape model reveals bird species differ in their capacity to habituate to humans."
Sutton, NM, MA Weston, PJ Guay, J Tregoweth, and JP O'Dwyer
4 March 2021
This readme file describes the data files and R script accompanying the above publication. For further questions please contact:
Excel file containing waterbird escape response data to human approach. See sheet two in the excel file for a key of all headings.
Tab delimited text file: same data as excel file of the same name. For use with our R script. Header names must not be changed (i.e. when using your own data, please use the same headings we have).
R script for inferring bird prior distributions, analyzing goodness of fit of models, and for calculating differences between inferred prior distributions. Steps for running the script and explanation of outputs are as follows:
Step 1: The following R packages must be installed:
- rootSolve
- hypergeo
- numDeriv
- optimx
- gsl
- dplyr
- tidyr
Step 2: Specify the path to a tab delimited data file, such as a text file, by copying the path in the quotation marks on line 18.
Step 3: Choose whether to include group size as a risk factor by setting FLRF on line 25 to TRUE (include group size) or FALSE (do not include group size).
Step 4: Lines 32-62 set species-specific energetic parameters that are held constant in our models. Adjust these parameters as needed depending on the species being considered (note that within species, results are typically qualitatively insensitive to the choice of these parameters).
Step 5: On line 69, specify the number of data sets to be generated during the goodness of fit test (data sets are randomnly generated by drawing from inferred distributions as part of an exact test for model goodness of fit). Smaller values will run much faster, but will sacrifice accuracy. You may also choose to not run the goodness of fit test by setting GOF on line 74 to FALSE.
Step 6: After setting a value in step 5, the code is ready to run, and the entire script may be sourced.
This script will output four tables (viewed in R automatically). Below are descriptions of these tables:
Table 1: GOFtest - This table shows results for the goodness of fit test. Table headings are:
Species: Species for which a prior distribution was inferred.
Activity Level: The human activity level at which the prior distribution was inferred.
Observed log likelihood: Log likelihood of observed data given our optimality model.
Mean generated log likelihood: Mean log likelihood from repeated random draws given MLE parameters in our model.
Percentile: Where the observed likelihood lies in the distribution of model generated likelihoods. This is a measure of how well our model can describe the data. If the observed likelihood lies in the bulk of the distribution, the model passes the goodness of fit test.
Table 2: FItest - This table shows the results of the Fisher Information analysis on MLE parameters. Table headings are:
Species: Species for which a prior distribution was inferred.
test: Indicates which activity level prior distributions are being compared.
resultp: Whether the MLE shape parameter p from the first activity level lies within the FI calculated confidence interval of the second activity level in the comparison. If at least one of resultp and resultq is FALSE, we conclude that the two distributions compared are significantly different.
resultq: Whether the MLE shape parameter q from the first activity level lies within the FI calculated confidence interval of the second activity level in the comparison. If at least one of resultp and resultq is FALSE, we conclude that the two distributions compared are significantly different.
p: One of two MLE shape parameters of the inferred prior distribution of the first activity level in the test column.
pCI: FI calculated confidence interval for one of two MLE shape parameters of the inferred prior distribution of the second activity level in the test column.
q: One of two MLE shape parameters of the inferred prior distribution of the first activity level in the test column.
qCI: FI calculated confidence interval for one of two MLE shape parameters of the inferred prior distribution of the second activity level in the test column.
Table 3: RelDiff - Absolute relative differences between the three prior distributions for each species. Table headings are:
Species: Species for which a prior distribution was inferred.
Comparison: Which two distributions are being compared.
Relative Difference: The absolute relative difference between the two distributions compared.
Table 4: MeanDiff - The mean relative differences across all three activity levels for each species. Table headings are:
Species: Species for which a prior distribution was inferred.
Mean Relative Difference: The average relative difference between high, mid, and low inferred prior distributions for each species.