This is the core function that implements the Bayesian inference. Currently, the only supported density model is a truncated Gaussian mixture. If a starting parameter vector (th0) is not provided, it is set by calling init_trunc_gauss_mix; the same vector is used for all sampling chains. Named elements of the variable control must consist of one of the following four options (defaults in parentheses):

  • num_chains

    The calibration_curve to use for masking is separately input to maintain

    consistency with previous versions of baydem. Number of chains (4)

  • samps_per_chain Number of samples per chain (2000)

  • warmup Number of warmup samples (samps_per_chain/2)

  • stan_control Additional control parameters to pass to stan (list())

  • mask Whether to mask the likelihood sum based on individual calibration (FALSE)

The calibration_curve to use for masking is separately input to maintain consistency with previous versions of baydem.

sample_theta(
  rc_meas,
  density_model,
  hp,
  calib_df,
  th0 = NA,
  init_seed = NA,
  stan_seed = NA,
  calibration_curve = "intcal20",
  control = list()
)

Arguments

rc_meas

The radiocarbon measurements (see import_rc_data).

density_model

The density model (see set_density_model).

hp

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

calib_df

The calibration data frame (see load_calib_curve).

th0

An optional parameter vector to initialize the Stan chains. If not provided, it is set by calling init_trunc_gauss_mix.

init_seed

An optional random number seed for determining the starting parameter vector using a maximum likelihood fit. If not provided, it is drawn. It should not be provided if th0 is provided.

stan_seed

An optional random number seed for the call to Stan. If not provided, it is drawn.

calibration_curve

The calibration curve to use for masking (only used control$mask is TRUE). The default is "intcal20". Other options are "shcal20" and "marine20". For further options see Bchron::BchronCalibrate.

Value

bayesian_soln, a list-like object of class bd_bayesian_soln with the following fields:

  • fit The result of the call to stan

  • final_th0 The final th0 value; i.e., never NA.

  • final_init_seed The final init_seed value; i.e., never NA unless th0 is provided.

  • final_stan_seed The final stan_seed value; i.e., never NA.

  • final_control The final control parameters used; i.e., if a parameter is not provided.

  • optional_inputs A record of the actual input values for the optional inputs, which are th0, init_seed, stan_seed, and control.

See also