cal_density: Kernel density estimation of calendar probability...

View source: R/cal_aggregate.R

cal_densityR Documentation

Kernel density estimation of calendar probability distributions

Description

Aggregates calibrated radiocarbon dates and other calendar probability distributions using the composite kernel density estimate (cKDE) method method \insertCiteBrown2017c14. This involves estimating the density of a set of dates by repeatedly computing the kernel density estimate of a random sample of ages drawn from their probability distributions.

Usage

cal_density(x, bw = 30, ..., times = 25, bootstrap = TRUE, strata = NULL)

## S3 method for class 'c14_cal'
density(x, ...)

Arguments

x

A cal vector of calendar probability distributions

bw

Kernel bandwidth size passed to stats::density(). Can be either an integer value or a character selection rule, but the latter will likely result in a different bandwidth being applied to each bootstrapped sample and therefore should be avoided. Default: 30 (years).

...

Further arguments passed to stats::density()

times

Number of bootstrap samples to generate. The default of 25 is suitable for testing but should be set much higher in practice.

bootstrap

If TRUE (the default), randomly resamples with replacement from x before each KDE calculation.

strata

If not NULL, KDEs will be weighted to ensure equal representation of classes specified by a factor or character vector. If bootstrap = TRUE, bootstrap samples are generated using stratified resampling of the same classes.

Details

cal_density(..., bootstrap = TRUE) performs composite kernel density estimation with bootstrapping \insertCiteMcLaughlin2019c14, where sampling error. x is estimated by randomly resampling x before each KDE calculation.

See \insertCiteMcLaughlin2019;textualc14 and \insertCiteCrema2022;textualc14 for discussions of bandwith selection.

Value

The result as a data frame or tibble::tibble with three columns: age (interpolated to common range of x), .estimate (mean of the bootstrapped KDEs), and .error (standard error of the bootstrapped KDEs).

References

\insertAllCited

See Also

Other functions for aggregating calendar probability distributions: cal_sum()

Examples

data(shub1_c14)
shub1_cal <- c14_calibrate(shub1_c14$c14_age, shub1_c14$c14_error)
cal_density(shub1_cal)

# Stratify and weight bootstrap estimation by phase
cal_density(shub1_cal, strata = shub1_c14$phase)

joeroe/c14 documentation built on Nov. 24, 2024, 11:47 p.m.