hamstr_bacon: A Wrapper for rbacon::Bacon

View source: R/hamstr-bacon.R

hamstr_baconR Documentation

A Wrapper for rbacon::Bacon

Description

Wraps the Bacon function from rbacon so that it can be used in a more typical "R" way. Returns age-depth models in a format to match hamstr output. Most Bacon functionality is accessible, for example hiatuses and boundaries, different calibration curves, postbomb curves. "accept.suggestions" defaults to TRUE so that the Bacon's accumulation rate prior suggestion is used by default, however, the section thickness parameter "thick" is by default allowed to be changed.

Usage

hamstr_bacon(
  id = "default",
  depth,
  obs_age,
  obs_err,
  thick = 5,
  d.min = NA,
  d.max = NA,
  d.by = NULL,
  seed = NA,
  acc.shape = 1.5,
  acc.mean = 20,
  mem.strength = 10,
  mem.mean = 0.5,
  boundary = NA,
  hiatus.depths = NA,
  hiatus.max = 10000,
  add = c(),
  cc = 1,
  cc1 = "IntCal20",
  cc2 = "Marine20",
  cc3 = "SHCal20",
  cc4 = "ConstCal",
  ccdir = "",
  postbomb = 0,
  delta.R = 0,
  delta.STD = 0,
  t.a = 3,
  t.b = 4,
  normal = FALSE,
  suggest = TRUE,
  accept.suggestions = TRUE,
  reswarn = c(10, 200),
  ask = FALSE,
  slump = c(),
  remove = FALSE,
  ssize = 2000,
  th0 = c(),
  burnin = min(500, ssize),
  youngest.age = c(),
  oldest.age = c(),
  plot.pdf = FALSE,
  close.connections = FALSE,
  verbose = FALSE,
  suppress.plots = TRUE,
  bacon.change.thick = FALSE
)

Arguments

depth

A vector of depths

obs_age

A vector of observed ages

obs_err

A vector of errors on the observed ages

thick

Bacon will divide the core into sections of equal thickness specified by thick (default thick=5).

d.min

Minimum depth of age-depth model (use this to extrapolate to depths higher than the top dated depth).

d.max

Maximum depth of age-depth model (use this to extrapolate to depths below the bottom dated depth).

d.by

Depth intervals at which ages are calculated. Defaults to d.by=1. Please ensure that the value of d.by is smaller than that of 'thick', otherwise plots might turn out wrong.

seed

Seed used for C++ executions. If it is not assigned (seed=NA; default) then the seed is set by system.

acc.shape

The prior for the accumulation rate consists of a gamma distribution with two parameters. Its shape is set by acc.shape (default acc.shape=1.5; higher values result in more peaked shapes).

acc.mean

The accumulation rate prior consists of a gamma distribution with two parameters. Its mean is set by acc.mean (default acc.mean=20 yr/cm (or whatever age or depth units are chosen), which can be changed to, e.g., 5, 10 or 50 for different kinds of deposits). Multiple values can be given in case of hiatuses or boundaries, e.g., Bacon(hiatus.depths=23, acc.mean=c(5,20))

mem.strength

The prior for the memory (dependence of accumulation rate between neighbouring depths) is a beta distribution, which looks much like the gamma distribution. but its values are always between 0 (no assumed memory) and 1 (100% memory). Its default settings of mem.strength=10 (higher values result in more peaked shapes) allow for a large range of posterior memory values. Please note that the default memory prior has been updated from rbacon version 2.5.1 on, to repair a bug.

mem.mean

The prior for the memory is a beta distribution, which looks much like the gamma distribution but its values are always between 0 (no assumed memory) and 1 (100% memory). Its default settings of mem.mean=0.5 allow for a large range of posterior memory values. Please note that the default memory prior has been updated from rbacon version 2.5.1. on, to repair a bug.

boundary

The assumed depths of any boundary, which divides sections of different accumulation rate regimes (e.g., as indicated by major change in the stratigraphy). No hiatus is assumed between these sections, and memory is reset crossing the boundary. Different accumulation priors can be set for the sections above and below the boundary, e.g., acc.mean=c(5, 20). See also hiatus.depths, mem.mean, acc.mean and acc.shape. Setting many boundaries might not work, and having more than one boundary per model section (see 'thick') might not work either.

hiatus.depths

The assumed depths for any hiatus should be provided as, e.g., hiatus.depths=20 for one at 20cm depth, and hiatus.depths=c(20,40) for two hiatuses at 20 and 40 cm depth.

hiatus.max

The prior for the maximum length of the hiatus. Hiatus length is a uniform distribution, with equal probabilities between 0 and hiatus.max yr (or whatever other age.unit is chosen).

add

Add a value to the maximum hiatus length if a boundary is chosen. Defaults to 100 yr (or whatever other age unit is chosen). Can be adapted if Bacon complains that the parameters are out of support.

cc

Calibration curve for C-14 dates: cc=1 for IntCal20 (northern hemisphere terrestrial), cc=2 for Marine20 (marine), cc=3 for SHCal20 (southern hemisphere terrestrial). For dates that are already on the cal BP scale use cc=0.

cc1

For northern hemisphere terrestrial 14C dates (IntCal20).

cc2

For marine 14C dates (Marine20).

cc3

For southern hemisphere 14C dates (SHCal20).

cc4

Provide the name of an alternative curve (3 columns: cal BP, 14C age, error, separated by white spaces and saved as a plain-text file). It is important here to first produce a tailor-made folder for your and the default calibration curves to live in. See cc.dir. Defaults to cc4="mixed.14C".

postbomb

Use a postbomb curve for negative (i.e. postbomb) 14C ages. 0 = none, 1 = NH1, 2 = NH2, 3 = NH3, 4 = SH1-2, 5 = SH3

delta.R

Mean of core-wide age offsets (e.g., regional marine offsets).

delta.STD

Error of core-wide age offsets (e.g., regional marine offsets).

t.a

The dates are treated using the t distribution (Christen and Perez 2009) by default (normal=FALSE). This t-distribution has two parameters, t.a and t.b, set at 3 and 4 by default (see Christen and Perez, 2010). If you want to assign narrower error distributions (more closely resembling the normal distribution), set t.a and t.b at for example 33 and 34 respectively (e.g., for specific dates in your .csv file). For symmetry reasons, t.a must always be equal to t.b-1.

t.b

The dates are treated using t distribution by default (normal=FALSE). The t-distribution has two parameters, t.a and t.b, set at 3 and 4 by default (see Christen and Perez, 2009). If you want to assign narrower error distributions (more closely resembling the normal distribution), set t.a and t.b at for example 33 and 34 respectively (e.g., for specific dates in your .csv file). For symmetry reasons, t.a must always be equal to t.b-1.

normal

By default, Bacon uses the t-distribution to treat the dates. Use normal=TRUE to use the normal/Gaussian distribution. This will generally give higher weight to the dates.

suggest

If initial analysis of the data indicates abnormally slow or fast accumulation rates, Bacon will suggest to change the prior.

accept.suggestions

Automatically accept the suggested values. Use with care. Default accept.suggestions=FALSE. Also, if the length of the core would cause too few or too many sections with the default settings, Bacon will suggest an alternative section thickness thick. Accept these suggested alternative settings by typing "y" (or "yes please" if you prefer to be polite), or leave as is by typing "n" (or anything else, really). To get rid of these suggestions, use suggest=FALSE.

reswarn

Bacon will warn you if the number of sections lies outside the safe range (default between 10 and 200 sections; reswarn=c(10,200)). Too few sections could lead to an ‘elbowy’ model while with too many sections the modelling process can get lost, resulting in age-models far away from the dated depths.

ask

By default Bacon will ask you to confirm that you want to run the core with the provided settings. Disable this using ask=FALSE (e.g., for batch runs).

slump

Upper and lower depths of any sections of assumed abrupt accumulation, that require excising before age-modelling (and adding after age-modelling). Requires pairs of depths, e.g., slump=c(10,15,60,67) for slumps at 67-60 and 15-10 cm core depth.

remove

Whether or not to remove depths within slumps. Defaults to remove=FALSE.

ssize

The amount of iterations to store at the end of the MCMC run. Default 4000; decrease for faster (but less reliable) runs or increase for cores where the MCMC mixing (panel at upper-left corner of age-model graph) appears problematic.

th0

Starting years for the MCMC iterations. These are randomly chosen by default.

burnin

Amount of initial, likely sub-optimal MCMC iterations that will be removed.

youngest.age

Minimum age limit for Bacon runs, default at current year in cal BP. To set plot limits, use age.min instead.

oldest.age

Maximum age limit for Bacon runs, default at 1,000,000 cal BP. To set plot limits, use age.max instead.

plot.pdf

Produce a pdf file of the age-depth plot. Defaults to plot.pdf=TRUE after a Bacon run.

close.connections

Internal option to close connections after a run. Default close.connections=TRUE.

verbose

Provide feedback on what is happening (default verbose=TRUE).

bacon.change.thick

Optionally allow Bacon to change the default or user supplied thick parameter

Examples

## Not run: 
hb1 <- hamstr_bacon(id = "sdf",
                    depth = MSB2K$depth,
                    obs_age = MSB2K$age,
                    obs_err = MSB2K$error
                    )

plot(hb1)
predict(hb1)
summary(hb1)

## End(Not run)

EarthSystemDiagnostics/hamstrbacon documentation built on June 2, 2025, 5:04 a.m.