Code supplement for the "The development of risk behaviors and their cultural transmission" by Alejandro Pérez Velilla, Bret Beheim & Paul E. Smaldino.
The repository contains a Julia project that must be activated and instantiated before use.
The notebooks repository contains a Pluto notebook that can be used to replicate all main text and supplementary plots, as well as to perform and plot individual model runs for exploratory purposes.
The paramscan directory contains the scripts used to run the parameter sweeps analyzed for the paper (see below), while the src directory contains the scripts pessimistic_learning_ABM.jl and pessimistic_learning_Numeric.jl which contain the ABM model code as well as helper functions for numeric analysis respectively, both of which are called by the aforementioned parameter-scanning scripts. To run the parameter scans, simply start a Julia session within the paramscan directory and use include(analysis_X.jl), replacing X with the numerical identifier for the desired analysis script. A word of caution: these simulations were performed in a high-performance computational cluster using parallelization. Attempting to run them without parallelization is most likely to lead to unfeasable simulation times for the full sweeps. You can tailor the number of parallel processes for the sweeps by editing the addprocs(N) line in the parameter scanning scripts, where N is the number of desired processes.
The data directory is the designated output location for parameter sweeps. Please unzip analysis_01.zip before running the Pluto notebook for the plots, as this output dataset was compressed to fit GitHub's file size guidelines.
Simulation data can also be found at https://osf.io/p5893/
The simulated data is organized in three different files, each generated by a corresponding parameter scanning script in the "paramscan" directory that can be found in the code repository. The scripts contain all information on how parameters were varied. The resulting CSV files are organized such that columns are parameters/outcome measures, and rows are individual runs of the agent-based model. Therefore, every row contains the parameters used and the outcomes obtained from a particular model run.
analysis_1.csv: Generated byanalysis_1.jl. Focuses on the evolution of learning strategies in static environments.analysis_1d.csv: Generated byanalysis_1d.jl. Focuses on the evolution of learning strategies under uncertain temporal change and varying levels of inter-individual correlation. Wealth buffers are evaluated at three values: 0.05, 0.5 and 0.95.analysis_2.csv: Generated byanalysis_2.jl. Examines the evolution of parochialism and the effects of economically-stratified populations.
analysis_0.csv: Generated byanalysis_0.jl. Elder influence is fixed at 0, peer influence and sensitivity are allowed to evolve in static environments while sweeping through aleph.analysis_1b.csv: Generated byanalysis_1b.jl. λ is fixed at 0. Focuses on varying μ with a fine grid of aleph values.analysis_1c.csv: Generated byanalysis_1c.jl. μ is fixed at 0. Focuses on varying λ with a fine grid of aleph values.
2 and 3 have "reduced" versions where μ (in 1b) and λ (in 1c) are fixed at 1 and only aleph is seeped through.
N: Total number of agents in the run.n: Number of peers sampled for learning.T: Total time periods in the gambling phase.t: Length of risk-free juvenile period.u: Environmental success probability for fixed environments.aleph: Wealth buffer.mu_std: Mutation rate for sensitivity to ruin.mu_soc_h: Mutation rate for horizontal social learning.mu_soc_v: Mutation rate for vertical and oblique social learning.mu_sens: Mutation rate for sensitivity to peer ruin.mu_L: Mutation rate for learning strategy.seed: Random seed for reproducibility.selection: Boolean indicating whether selection is enabled.mixed: Boolean indicating whether population stratification is used.
-
Analysis 0: Evolution of peer influence and sensitivity
- No additional parameters.
-
Analysis 1: Evolution of learning strategies in static and stochastically-fluctuating environments
m: Number of elders sampled for learning.μ: Probability that an agent draws a local environment independent of the aggregate environment.λ: Probability that a new aggregate environment is drawn at the beginning of a new generation.
-
Analysis 2: Parochialism and Stratified Populations
mu_parochial: Mutation rate for parochialism.mixed_freq: Relative frequency of Group 0 in stratified populations.mixed_aleph1,mixed_aleph2: Wealth buffer values for stratified groups.mixed_u1,mixed_u2: Environmental success probabilities for stratified groups.
Vbar: Mean population-wide wealth.s_mean: Mean population-wide stake.s_median: Median population-wide stake.concentration: Stake concentration in the population.
All analyses contain the outcome variables of the preceding analyses, while at the same time adding new ones.
-
Analysis 0
soc_h_median,soc_h_lerror,soc_h_herror: Median, lower, and upper error bounds for horizontal social learning reliance.sens_median,sens_lerror,sens_herror: Median, lower, and upper error bounds for sensitivity to peer ruin.s_young_median,s_young_lerror,s_young_herror: Stakes among younger individuals.
-
Analysis 1
soc_v_median,soc_v_lerror,soc_v_herror: Metrics for vertical social learning reliance.freq_ub,freq_pb: Frequencies of unbiased and payoff-biased learners.s_end_mean,s_end_median: Stakes at the end of life.s_child_mean,s_child_median: Stakes for juveniles.
-
Analysis 2
Vbar_g0,Vbar_g1: Mean wealth for Groups 0 and 1.freq_ub_g0,freq_ub_g1: Frequencies of unbiased learners in Groups 0 and 1.freq_parochial_g0,freq_parochial_g1: Frequencies of parochial learners in Groups 0 and 1.s_median_g0,s_median_g1: Median stakes for Groups 0 and 1.