DOI: 10.5281/zenodo.10061467
title: Data and scripts for the paper 'Frequent disturbances enhance the resistance and recovery of past human populations'

description: This repository contains scripts and data to reproduce the results reported in the paper 'Frequent disturbances enhance the resistance and recovery of past human populations'.

The repository is organised into six main folders:

data - radiocarbon date tables for 16 regions

scripts - R scripts for running Bayesian MCMC models, statistical modelling of results, and producing outputs

fits & output - the results of running the above scripts

figures & supplement - figures and tables produced for the paper

 

Data

Raw data for the MCMC analysis can be found in the data folder, comprising 18 tables (.csv) of archaeological radiocarbon dates.

Bayesian MCMC Analysis

Code for performing Bayesian Markov Chain Monte Carlo analysis on aggregated radiocarbon data (mcmc.R). Please note that, given the long processing time and memory requirements for each MCMC fit, the script contains code to reproduce a single example: Southeastern Norway. This is one of the smaller datasets (617 dates), and takes approximately ~6 hours to complete on an Intel(R) Core(TM) i5-9600 CPU @ 3.10GHz with 16 GB of DDR3 RAM. However, any of the 18 radiocarbon datasets can be substituted in this script and the parameters altered per Table S1 to obtain posteriors for any case study.

The output folder contains the full results of the bayesian MCMC analysis: MCMC diagnostics, parameters, posterior checks, and resistance-resilience metrics collected on each fit, including traceplots, Rhat, and ESS checks.

Resistance-resilience metrics

Code for the resmet() function is also contained in the mcmc.R file. resmet() is an adaptation of Edinborough et al.'s post-hoc statistical test for demographic events in written and oral history (https://doi.org/10.1073/pnas.1713012114). The inspiration for this function - p2pTest() in rcarbon - is for use with objects of class SpdModelTest. This function extends the principle to spdppc objects.

Following, principally, Riris and De Souza (2021; https://doi.org/10.3389/fevo.2021.740629), Nimmo et al. (2015; https://doi.org/10.1016/j.tree.2015.07.008), Cantarello et al. (2017; https://doi.org/10.1002/ece3.3491), and Van Meerbeek et al. (2021; https://doi.org/10.1111/1365-2745.13651), this will perform post-hoc tests for resistance and resilience on marks of an spdppc object over all periods where SPDs are below growth model expectations ('downturns'). These two metrics are defined as the ability to absorb disturbances and "bounce back" following disturbances, respectively. They are normalised relative to the value of the SPD at the start of the interval of interest.

The function outputs a data frame containing the value of both metrics, as well as the duration, end- and start-times of downturns, and the time to SPD minimum, all in calendar years Before Present. Parameter 'LD' is the Time to SPD minimum normalised by the downturn duration - which we term 'Pace'.

Raw results on individual posterior predictive checks can be found in the mcmc_metrics subfolder. resistance-resilience_metrics.csv contains the compiled, cleaned, and annotated dataset used in statistical modelling.

Statistical Modelling

Code for performing linear mixed-effect modelling on resistance-resilience metrics is contained in the statisticalmodelling.R file. It generates fitted models and diagnostics from the file resistance-resilience_metrics.csv

Display items

Figures and tables for the main paper text and the Materials & Methods can be found in the relevant sub-folders. The plotting.R script produces the figures. 

 

R session information

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8   
[3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] coda_0.19-4.1      RColorBrewer_1.1-3 patchwork_1.1.3    reshape2_1.4.4     ggplot2_3.4.3     
 [6] scales_1.2.1       effects_4.2-2      carData_3.0-5      sjPlot_2.8.15      dplyr_1.1.3       
[11] here_1.0.1         nimbleCarbon_0.2.5 nimble_1.0.1       rcarbon_1.5.1     

loaded via a namespace (and not attached):
 [1] sjlabelled_1.2.0       tidyselect_1.2.0       pracma_2.4.2           spatstat.geom_3.2-5   
 [5] spatstat.explore_3.2-3 bayestestR_0.13.1      sjstats_0.18.2         rpart_4.1.19          
 [9] estimability_1.4.1     lifecycle_1.0.3        sf_1.0-14              survival_3.5-5        
[13] spatstat.data_3.0-1    magrittr_2.0.3         compiler_4.3.1         rlang_1.1.1           
[17] doSNOW_1.0.20          tools_4.3.1            igraph_1.5.1           utf8_1.2.3            
[21] knitr_1.44             classInt_0.4-10        plyr_1.8.8             abind_1.4-5           
[25] KernSmooth_2.23-21     withr_2.5.1            numDeriv_2016.8-1.1    purrr_1.0.2           
[29] nnet_7.3-19            grid_4.3.1             polyclip_1.10-6        fansi_1.0.4           
[33] xtable_1.8-4           e1071_1.7-13           colorspace_2.1-0       emmeans_1.8.8         
[37] iterators_1.0.14       MASS_7.3-60            spatstat.utils_3.0-3   spatstat_3.0-6        
[41] insight_0.19.5         survey_4.2-1           cli_3.6.1              mvtnorm_1.2-3         
[45] generics_0.1.3         rstudioapi_0.15.0      performance_0.10.5     modelr_0.1.11         
[49] minqa_1.2.6            DBI_1.1.3              proxy_0.4-27           stringr_1.5.0         
[53] splines_4.3.1          spatstat.model_3.2-6   mitools_2.4            vctrs_0.6.3           
[57] boot_1.3-28.1          Matrix_1.6-4           tensor_1.5             foreach_1.5.2         
[61] tidyr_1.3.0            units_0.8-4            snow_0.4-4             goftest_1.2-3         
[65] glue_1.6.2             spatstat.random_3.1-6  nloptr_2.0.3           codetools_0.2-19      
[69] stringi_1.7.12         gtable_0.3.4           deldir_1.0-9           ggeffects_1.3.1       
[73] lme4_1.1-34            munsell_0.5.0          tibble_3.2.1           pillar_1.9.0          
[77] R6_2.5.1               rprojroot_2.0.3        lattice_0.21-8         backports_1.4.1       
[81] broom_1.0.5            class_7.3-22           Rcpp_1.0.11            spatstat.linnet_3.1-1 
[85] nlme_3.1-162           spatstat.sparse_3.0-2  mgcv_1.8-42            xfun_0.40             
[89] sjmisc_2.8.9           pkgconfig_2.0.3