Learn R Programming

carbondate

An R package to analyse, and summarise, multiple radiocarbon (14C) determinations. The package provides two linked (but distinct) Bayesian approaches that can both be used to obtain rigorous and robust alternatives to summed probability distributions (SPDs):

  • Bayesian Non-Parametric Density Estimation (Modelling the joint, summary, calendar distribution as an unknown mixture of calendar age clusters) — see “Non-parametric calibration of multiple related radiocarbon determinations and their calendar age summarisation” (Heaton, 2022).
  • Variable-Rate Poisson Process Estimation (Modelling changes in the occurrence rate of the 14C samples over calendar time) — see “A New Approach to Radiocarbon Summarisation: Rigorous Identification of Variations/Changepoints in the Occurrence Rate of Radiocarbon Samples using a Poisson Process” (Heaton et al., to appear)

Both methods are implemented using Markov Chain Monte Carlo (MCMC).

Installation

The easiest way to install the latest release is via CRAN, by typing the following into your R console:

install.packages("carbondate")

You can alternatively install the development version of carbondate from GitHub with:

devtools::install_github("TJHeaton/carbondate")

Once you have installed the library with either of the above methods, you need to load it using:

library(carbondate)

Data

There are a few example datasets of radiocarbon determinations (e.g., two_normals, kerr, pp_uniform_phase, buchanan, alces, equus, human, …) provided, which can be used to try out the calibration functions. two_normals is a small simulated dataset for which the underlying calendar ages were drawn from a known mixture of two normals. It is included simply to give a quick-to-run example for the Bayesian Non-Parametric Density calibration functions. pp_uniform_phase is another small simulated dataset, for which the underlying calendar ages were drawn uniformly at random from a short calendar interval (equivalent to a single uniform phase). This is included to give a quick-to-run example for the Poisson Process modelling functions. The remaining datasets are from real-life data. The Northern Hemisphere IntCal calibration curves and Southern Hemisphere SHCal calibration curves are also provided.

Bayesian Non-Parametric Calibration: Quick-Start Example

The below example implements the Bayesian non-parametric calibration and summarisation approach on the simulated two_normal data using the IntCal20 curve via two (slightly) different MCMC methods.

polya_urn_output <- PolyaUrnBivarDirichlet(
  rc_determinations = two_normals$c14_age,
  rc_sigmas = two_normals$c14_sig,
  calibration_curve=intcal20)

walker_output <- WalkerBivarDirichlet(
  rc_determinations = two_normals$c14_age,
  rc_sigmas = two_normals$c14_sig,
  calibration_curve=intcal20)

Once the calibration has been run, the resultant estimate for the joint (summary) calendar age density can be plotted.

PlotPredictiveCalendarAgeDensity(
  output_data = list(polya_urn_output, walker_output),
  show_SPD = TRUE)

The summary estimates generated by the Bayesian non-parametric approach (shown in purple and green) are called predictive densities. They aim to predict the calendar age of a future (new) sample based upon the set of 14C samples that you have summarised.

Poisson Process Modelling: Quick-Start Example

The below example implements the Poisson process modelling approach using the simulated pp_uniform_phase data and the IntCal20 curve.

pp_output <- PPcalibrate(
  rc_determinations = pp_uniform_phase$c14_age,
  rc_sigmas = pp_uniform_phase$c14_sig,
  calibration_curve=intcal20)

Once the calibration has been run, the posterior estimate for the occurrence rate of the samples can be plotted.

PlotPosteriorMeanRate(output_data = pp_output)

This estimated rate, and changes within it, can be interpreted equivalently to methods of calendar age summarisation.

Copy Link

Version

Install

install.packages('carbondate')

Monthly Downloads

376

Version

1.1.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Timothy J Heaton

Last Published

April 8th, 2025

Functions in carbondate (1.1.0)

PlotPosteriorHeights

Plot Heights of Segments in Rate of Sample Occurrence for Poisson Process Model
PlotPredictiveCalendarAgeDensity

Plot Predictive Estimate of Shared Calendar Age Density from Bayesian Non-Parametric DPMM Output
PlotRateIndividualRealisation

Plot Individual Realisations of Posterior Rate of Sample Occurrence for Poisson Process Model
PlotNumberOfInternalChanges

Plot Number of Changepoints in Rate of Sample Occurrence for Poisson Process Model
PlotNumberOfClusters

Plot Number of Calendar Age Clusters Estimated in Bayesian Non-Parametric DPMM Output
PlotGelmanRubinDiagnosticSingleChain

Plot Histogram of the Gelman-Rubin Convergence Diagnostic for a Single MCMC Chain
PolyaUrnBivarDirichlet

Calibrate and Summarise Multiple Radiocarbon Samples via a Bayesian Non-Parametric DPMM (with Polya Urn Updating)
PlotPosteriorChangePoints

Plot Calendar Ages of Changes in Rate of Sample Occurrence for Poisson Process Model
PlotPosteriorMeanRate

Plot Posterior Mean Rate of Sample Occurrence for Poisson Process Model
armit

Example real-life data - Population Decline in Iron Age Ireland
WalkerBivarDirichlet

Calibrate and Summarise Multiple Radiocarbon Samples via a Bayesian Non-Parametric DPMM (with Walker Updating)
intcal04

IntCal04 calibration curve
human

Example real-life data - Humans in Yukon and Alaska
cervus

Example real-life data - Cervus in Yukon and Alaska
buchanan

Example real-life data - Palaeo-Indian demography
bison

Example real-life data - Bison in Yukon and Alaska
intcal09

IntCal09 calibration curve
pp_uniform_phase

Example artificial data - Uniform Phase
alces

Example real-life data - Alces in Yukon and Alaska
intcal20

IntCal20 calibration curve
intcal98

IntCal98 calibration curve
intcal13

IntCal13 calibration curve
equus

Example real-life data - Equus in Yukon and Alaska
kerr

Example real-life data - Irish Rath
shcal04

SHCal04 calibration curve
mammuthus

Example real-life data - Mammuthus in Yukon and Alaska
shcal20

SHCal20 calibration curve
shcal13

SHCal13 calibration curve
two_normals

Example artificial data - Mixture of Normal Phases
PlotCalendarAgeDensityIndividualSample

Plot Posterior Calendar Age Estimate for an Individual Determination after Joint Calibration
CalibrateSingleDetermination

Calibrate a Single Radiocarbon Determination
InterpolateCalibrationCurve

Interpolate a calibration curve at a set of calendar ages
GenerateOxcalCode

Outputs code suitable for running in OxCal from a series of radiocarbon determinations
FindSummedProbabilityDistribution

Find the summed probability distribution (SPD) for a set of radiocarbon observations
FindPredictiveCalendarAgeDensity

Find Predictive Estimate of Shared Calendar Age Density from Bayesian Non-Parametric DPMM Output
PlotConvergenceData

Plot KL Divergence of Predictive Density to Assess Convergence of Bayesian Non-Parametric DPMM Sampler
PPcalibrate

Model Occurrence of Multiple Radiocarbon Samples as a Variable-Rate Poisson Process
PlotGelmanRubinDiagnosticMultiChain

Plot Histogram of the Gelman-Rubin Convergence Diagnostic for Multiple Independent MCMC Chains
FindPosteriorMeanRate

Find Posterior Mean Rate of Sample Occurrence for Poisson Process Model