Skip to content

Latest commit

 

History

History
162 lines (111 loc) · 6.07 KB

README.md

File metadata and controls

162 lines (111 loc) · 6.07 KB

price2020

This repository contains the data and code for our paper:

Price, M.H., J.M. Capriles, J. Hoggarth, R.K. Bocinsky, C.E. Ebert, and J.H. Jones, (2020). End-to-end Bayesian analysis of radiocarbon dates reveals new insights into lowland Maya demography. In review.

How to cite

Please cite this compendium as:

Price, M.H., J.M. Capriles, J. Hoggarth, R.K. Bocinsky, C.E. Ebert, and J.H. Jones, (2020). Compendium of R code and data for End-to-end Bayesian analysis of radiocarbon dates reveals new insights into lowland Maya demography. Accessed 21 Jun 2020.

Getting the code and input data

The easiest way to get the code and input data is to clone this github repository. For example, enter the following at the command line to clone the repository, enter the newly-created directory, and list its contents:

git clone https://github.com/eehh-stanford/price2020
cd price2020
ls

Requirements

This research compendium has been developed using the statistical programming language R. To work with the compendium, you will need the R software itself and optionally RStudio Desktop.

To install the R packages that the code depends on enter the following in R:

# install.packages("devtools")
devtools::install()

Among other things, this installs the following package:

https://github.com/eehh-stanford/baydem

This also installs Rstan, which may have further depenencies. If so, see:

https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

Some detailes on the package/version dependencies, imports, and suggestions are available in the package DESCRIPTION file.

Contents

  • Input data files:
    • MesoRAD-v.1.1_FINAL_no_locations.xlsx
    • Tikal_Demography.xlsx
  • R files:
    • bayesian_radiocarbon_functions.R
    • create_identif_results_exp.R
    • create_identif_results_gm.R
    • do_maya_inference.R
    • do_sim_inference.R

The remaining files are for the README and R package.

Running the analyses

Simulation

If necessary, set the R working directory to the directory with the files (e.g., using setwd). Then type the following in R:

source('do_sim_inference.R')

This should take a few hours to finish. Once complete, the following new files are created:

  • sim_inference.rds
  • Fig1_sim_inference.pdf

sim_inference.rds stores the results of the Bayesian inference for N=10, 100, 1000,and 10000 simulated radiocarbon samples and two choices for the paramaterization of the prior (a total of eight cases). Fig1_sim_inference.pdf is Figure 1 in the article.

Maya results

If necessary, set the R working directory to the directory with the files (e.g., using setwd). Then type the following in R:

source('do_maya_inference.R')

This should take about two days to finish. Once complete, the following new files are created:

  • Mesorad files
    • log_mesorad_hygiene_counts.csv
    • mesorad_filtered.csv
    • log_mesorad_filtered_site_counts.csv
    • mesorad_combined.csv
    • mesorad_final.csv
  • Inference results
    • maya_inference_K2_tik.rds
    • maya_inference_K4_tik.rds
    • maya_inference_K6_tik.rds
    • maya_inference_K8_tik.rds
    • maya_inference_K10_tik.rds
    • maya_inference_K2_all.rds
    • maya_inference_K4_all.rds
    • maya_inference_K6_all.rds
    • maya_inference_K8_all.rds
    • maya_inference_K10_all.rds
  • Figures and count data
    • Fig2_maya_inference_K10.pdf
    • Fig3_tikal_prev_expert_comparison.pdf
    • Fig4_maya_inference_rate_K10.pdf
    • Fig5_maya_histograms.pdf
    • FigS3_maya_inference_Kall.pdf
    • FigS4_maya_inference_K2_and_K10_with_rc_curve.pdf
    • supp_count_data.csv

The first set of files provides the Mesorad data at various stages of processing. The second set of files (maya_inference_K) provides the inference results for Tikal/All sites with K=2 to 10 numbers of mixtures components. The third set of files is the figures and count data for the main manuscript and supplement.

Identifiability results (supplement)

If necessary, set the R working directory to the directory with the files (e.g., using setwd). There are two scripts to run, one for the exponential example and one for the Gaussian mixture example. For the exponential example type:

source('create_identif_results_exp.R')

This should take only a few minutes to run. Once complete, the following new files are created:

  • FigS1_exp_example.pdf
  • SuppB_exp.csv

FigS1_exp_example.pdf is Figure S1 in the supplement. SuppB_exp.csv provides summary information for the example, notably the mean measurement uncertainties reported in the supplement.

For the Gaussian mixture example type:

source('create_identif_results_gm.R')

This will take a few hours to run. Once complete, the following new file is created:

  • FigS2_gm_example.pdf

FigS2_exp_example.pdf is Figure S2 in the supplement. Information about the identifiability checks is printed out in R as the script runs.

Licenses

Text and figures : CC-BY-4.0

Code : See the DESCRIPTION file

Data : CC-0 attribution requested in reuse

Contributions

We welcome contributions from everyone. Before you get started, please see our contributor guidelines. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.