This is one of a set of helper functions for undertaking a typical analysis of radiocarbon dates. For details on the overall framework for these helper function, see set_rc_meas.

#' To ensure reproducibility, the input seed can be provided. The input seed should either be (1) NA the default, (2) a single integer, or (3) a matrix with dimensions num_models by 2, where num_models = length(analysis$density_model$K). If no seed is provided, one is drawn and treated as if it (a single integer) was input. If a single integer is provided, it is used to generate a matrix of integers with dimensions num_models by 2. The first column of the matrix provides the seeds for initializing the parameter vector and the second column provides the seeds for stan.

The best model is identified based on the Pareto smoothed importance sampling (PSIS) approximation of the leave-one-out (loo) cross-validation (CV), PSIS-LOO CV (just loo in the code). The corresponding index (in density_model$K) and K-value are stored in, respectively, m_K_best and K_best (currently, only a truncated Gaussian mixture is supported for the density model specification). The vector of loo values is stored in loo_vect. The model with the highest loo is prefered. WAIC values are also calculated and stored in waic_vect.

do_bayesian_inference(
  data_dir,
  analysis_name,
  hp,
  input_seed = NA,
  control = list()
)

Arguments

data_dir

The directory in which to store analysis data.

analysis_name

A unique name for a given analysis in data_dir.

hp

Hyperparameters for the priors and to specify the spacing of the Riemann sum that approximates the integral for the likelihood (see sample_theta).

input_seed

An optional seed that can be used to make results reproducible. The input_seed must be either (1) NA / not provided (the default), (2) a single integer, or (3) a matrix with dimensions num_models by 2 (see description for further details).

Control

arguments to pass to the Bayesian inference function (see sample_theta).

See also

set_sim() for an overview of the "standard pipeline"