-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
174 lines (119 loc) · 6.06 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
# Please put your title here to include it in the file below.
Title <- "End-to-end Bayesian analysis of radiocarbon dates reveals new insights into lowland Maya demography"
```
# 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). _`r Title`_. In review.
<!-- Our pre-print is online here: -->
<!-- > Authors, (YYYY). _`r Title`_. Name of journal/book, Accessed `r format(Sys.Date(), "%d %b %Y")`. Online at <https://doi.org/xxx/xxx> -->
### 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, (`r format(Sys.Date(), "%Y")`). _Compendium of R code and data for `r Title`_. Accessed `r format(Sys.Date(), "%d %b %Y")`.
## 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:
```console
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](https://cloud.r-project.org/) itself and optionally [RStudio
Desktop](https://rstudio.com/products/rstudio/download/).
To install the R packages that the code depends on enter the following in *R*:
``` r
# install.packages("devtools")
devtools::install()
```
Among other things, this installs the following package:
[https://github.com/eehh-stanford/baydem](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](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:
``` 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:
``` 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:
``` r
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:
``` r
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](http://creativecommons.org/licenses/by/4.0/)
**Code :** See the [DESCRIPTION](DESCRIPTION) file
**Data :** [CC-0](http://creativecommons.org/publicdomain/zero/1.0/) attribution requested in reuse
### Contributions
We welcome contributions from everyone. Before you get started, please see our [contributor guidelines](CONTRIBUTING.md). Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.