Skip to contents

Given output from the Poisson process fitting function PPcalibrate calculate the posterior mean rate of sample occurrence (i.e., the underlying Poisson process rate \(\lambda(t)\)) together with specified probability intervals, on a given calendar age grid (provided in cal yr BP).

Note: If you want to calculate and plot the result, use PlotPosteriorMeanRate instead.

For more information read the vignette:
vignette("Poisson-process-modelling", package = "carbondate")

Usage

FindPosteriorMeanRate(
  output_data,
  calendar_age_sequence,
  n_posterior_samples = 5000,
  interval_width = "2sigma",
  bespoke_probability = NA,
  n_burn = NA,
  n_end = NA
)

Arguments

output_data

The return value from the updating function PPcalibrate. Optionally, the output data can have an extra list item named label which is used to set the label on the plot legend.

calendar_age_sequence

A vector containing the calendar age grid (in cal yr BP) on which to calculate the posterior mean rate.

n_posterior_samples

Number of samples it will draw, after having removed n_burn, from the (thinned) MCMC realisations stored in output_data to estimate the rate \(\lambda(t)\). These samples may be repeats if the number of, post burn-in, realisations is less than n_posterior_samples. If not given, 5000 is used.

interval_width

The confidence intervals to show for both the calibration curve and the predictive density. Choose from one of "1sigma" (68.3%), "2sigma" (95.4%) and "bespoke". Default is "2sigma".

bespoke_probability

The probability to use for the confidence interval if "bespoke" is chosen above. E.g., if 0.95 is chosen, then the 95% confidence interval is calculated. Ignored if "bespoke" is not chosen.

n_burn

The number of MCMC iterations that should be discarded as burn-in (i.e., considered to be occurring before the MCMC has converged). This relates to the number of iterations (n_iter) when running the original update functions (not the thinned output_data). Any MCMC iterations before this are not used in the calculations. If not given, the first half of the MCMC chain is discarded. Note: The maximum value that the function will allow is n_iter - 100 * n_thin (where n_iter and n_thin are the arguments that were given to PPcalibrate) which would leave only 100 of the (thinned) values in output_data.

n_end

The last iteration in the original MCMC chain to use in the calculations. Assumed to be the total number of iterations performed, i.e. n_iter, if not given.

Value

A list, each item containing a data frame of the calendar_age_BP, the rate_mean and the confidence intervals for the rate - rate_ci_lower and rate_ci_upper.

Examples

# NOTE: All these examples are shown with a small n_iter and n_posterior_samples
# to speed up execution.
# Try n_iter and n_posterior_samples as the function defaults.

pp_output <- PPcalibrate(
    pp_uniform_phase$c14_age,
    pp_uniform_phase$c14_sig,
    intcal20,
    n_iter = 1000,
    show_progress = FALSE)

# Default plot with 2 sigma interval
FindPosteriorMeanRate(pp_output, seq(450, 640, length=10), n_posterior_samples = 100)
#>    calendar_age_BP  rate_mean rate_ci_lower rate_ci_upper
#> 1         450.0000 0.02652925   0.002534426    0.05217793
#> 2         471.1111 0.02934888   0.005977875    0.06644602
#> 3         492.2222 0.03138208   0.005977875    0.09191301
#> 4         513.3333 0.79113405   0.613138526    0.88529633
#> 5         534.4444 0.79113405   0.613138526    0.88529633
#> 6         555.5556 0.34909595   0.002836854    0.78321291
#> 7         576.6667 0.01912272   0.005036594    0.09166295
#> 8         597.7778 0.01484077   0.005036594    0.02796642
#> 9         618.8889 0.01642518   0.009355194    0.04376152
#> 10        640.0000 0.01568299   0.004895063    0.04376152