| Title: | Archaeological Synchronism |
| Version: | 1.0.2 |
| Description: | Estimation of unknown historical or archaeological dates subject to relationships with other relative dates and absolute constraints, derived as marginal densities from the full joint conditional, using a two-stage Gibbs sampler with consistent batch means to assess convergence. Features reporting on Monte Carlo standard errors, as well as tools for rule-based estimation of dates of production and use of artifact types, aligning and checking relative sequences, and evaluating the impact of the omission of relative/absolute events upon one another. |
| License: | GPL (≥ 3) |
| Imports: | stats, graphics, grDevices, Rcpp, Rdpack, paletteer |
| RdMacros: | Rdpack |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| LinkingTo: | Rcpp |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | yes |
| Packaged: | 2026-10-01 21:53:21 UTC; archaeologus |
| Author: | Stephen A. Collins-Elliott
|
| Maintainer: | Stephen A. Collins-Elliott <sce@utk.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-01 22:40:02 UTC |
Create an Absolute Constraint Object
Description
Analogous to the list function, to create absolute constraint (terminus post quem or ante quem). The constraint must contain named elements of "id", "assoc", and "samples", with an option to indicate "type".
Usage
absolute(id, assoc, type = NULL, samples)
## S3 method for class 'character'
absolute(id, assoc, type = NULL, samples)
Arguments
id |
a |
assoc |
the element within an |
type |
(optional) a |
samples |
a vector of samples drawn from the appertaining probability density function of that constraint |
Value
An absolute object.
Examples
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = "RIC2 57", samples = seq(37, 41, length = 100))
# seq(37, 41, length = 100) is equivalent in concept to runif(100, 37, 41))
destr <- absolute(id = "destr", assoc = "J", samples = 79)
coin1
coin2
destr
Create an Assemblage Object
Description
Analogous to the sequences or constraints function for relative and absolute events, this function collects one or more finds objects into a single object, for input into gibbs_ad_type.
Usage
assemblage(...)
## S3 method for class 'finds'
assemblage(...)
## S3 method for class 'list'
assemblage(...)
Arguments
... |
one or more |
Value
An assemblage object.
Examples
f1 <- finds(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- finds(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- finds(id = "find03", assoc = "G", type = c("type1", "form1"), residual = TRUE)
f4 <- finds(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- finds(id = "find05", assoc = "I", type = "type2")
f6 <- finds(id = "find06", assoc = "H")
finds_all <- assemblage(f1, f2, f3, f4, f5, f6)
finds_all
Create an Constraints Object
Description
Analogous to the sequences function for relative events, this function collects one or more absolute objects into a single object, for input into gibbs_ad.
Usage
constraints(...)
## S3 method for class 'absolute'
constraints(...)
## S3 method for class 'list'
constraints(...)
Arguments
... |
one or more |
Value
A constraints object.
Examples
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = "RIC2 57", samples = seq(37, 41, length = 100))
# seq(37, 41, length = 100) is equivalent in concept to runif(100, 37, 41))
destr <- absolute(id = "destr", assoc = "J", samples = 79)
tpq <- constraints(coin1, coin2)
taq <- constraints(destr)
tpq
taq
Create an Events Object
Description
Analogous to the c function, to create a sequence of unique events as a vector. Elements may not contain names of "alpha" or "omega", which are restricted for quae_antea and quae_postea.
Usage
events(...)
## S3 method for class 'character'
events(...)
Arguments
... |
Comma separated character elements, in order from left (earliest) to right (latest). |
Value
An events object.
Examples
# "A" before "B", "B" before "C"
x <- events("A", "B", "C")
x
Create an Finds Object
Description
Analogous to the list function, to create an object of a find (e.g., artifact or other element) related to a particular context or event. The find must contain named elements of "id" and "assoc", with optional inputs of "type" and "residual", to be collected into a single object via the assemblage function. Finds which are datable to absolute constraints should be created as an absolute object.
Usage
finds(id, assoc, type = NULL, residual = FALSE)
## S3 method for class 'character'
finds(id, assoc, type = NULL, residual = FALSE)
Arguments
id |
a |
assoc |
the element (e.g., context) within an |
type |
(optional) a |
residual |
(optional) if |
Value
A finds object.
Examples
f1 <- finds(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- finds(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- finds(id = "find03", assoc = "G", type = c("type1", "form1"), residual = TRUE)
f4 <- finds(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- finds(id = "find05", assoc = "I", type = "type2")
f6 <- finds(id = "find06", assoc = "H")
f1
f2
f3
f4
f5
f6
Gibbs Sampler for Archaeological Dates
Description
A Gibbs sampler for dating archaeological events, to fit relative sequences to absolute, calendrical dates. Relative events can be associated with termini post quos (t.p.q.) and termini ante quos (t.a.q.), which are entered as samples from a given probability density function f(t). This function may take any form, a single date (i.e., with a probability of 1), a continuous uniform distribution (any time between two dates), or a bespoke density (as with calibrated radiocarbon dates). Relative events are modeled on a continuous uniform density between the latest antecedent event and earliest subsequent event.
Usage
gibbs_ad(
sequences,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
trim = TRUE,
quiet = FALSE
)
## S3 method for class 'sequences'
gibbs_ad(
sequences,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
trim = TRUE,
quiet = FALSE
)
## S3 method for class 'list'
gibbs_ad(
sequences,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
trim = TRUE,
quiet = FALSE
)
Arguments
sequences |
A |
max_samples |
Maximum number of samples to run. Default is |
size |
The number of samples to take on each iteration of the main Gibbs sampler. Default is |
mcse_crit |
Criterion for the Monte Carlo standard error to stop the Gibbs sampler, as based on depositional dates and absolute constraints. The number of Monte Carlo samples for production dates is identical to that depositional dates. |
tpq |
A |
taq |
A |
alpha_ |
An initial t.p.q. to limit any elements which may occur before the first provided t.p.q. Default is |
omega_ |
A final t.a.q. to limit any elements which may occur after the after the last provided t.a.q. Default is |
trim |
A logical value to determine whether elements that occur before the first t.p.q. and after the last t.a.q. should be omitted from the results (i.e., to "trim" elements at the ends of the sequence, whose marginal densities depend on the selection of |
quiet |
Whether to supress messages/progress output while function is running. Default is |
Details
Gibbs sampling is a conventional method for calibrating and estimating radiocarbon dates in light of absolute constraints and relative sequences: see Buck et al. (1996); Buck et al. (1999); Bronk Ramsey (2009).
In this implementation, two phases of Gibbs sampling are performed: an initial phase for selecting starting values and then the main sampler, with convergence evaluated using Monte Carlo standard errors (MCSE).
The initial Gibbs sampler results in a vector of starting values randomly sampled for each event up to \sqrt{k} runs, where k is the total number of events. Starting values may therefore take some time to assign, but this initial sampling is necessary to avoid a catastrophic collapse due to floating point errors in the initial selection of random values and will also result in closer starting values with respect to marginal densities.
The main Gibbs sampler uses consistent batch means (CBM) determine convergence and hence when to end the main sampling run: there is no motivation to remove burn-in from the main sampling run nor to run multiple chains. CBM is assured to converge in distribution, see Jones et al. (2006); Flegal et al. (2008). A stopping point for the main sampler is therefore determined using the mean of the Monte Carlo standard errors (MCSE) across all random variates, which is the input of mcse_crit (the mean MCSE for all events). The input max_samples indicates the maximum number of simulations to run, but the sampler will stop if the specified criterion of mcse_crit is passed. The default mean MCSE is set at mcse_crit = 0.5, as the MCSE is measured in years (i.e. to allow for an error +/- 1 year), but, to be sure, individual events will have higher or lower MCSE than this mean criterion, whose primary purpose is as a stopping rule.
Note that the MCSE criterion is applied as a stopping rule for depositional dates and external constraints. The number of Monte Carlo samples for production dates of types is chosen to be identical to that need to pass mcse_crit, such that ultimately the final mean MCSE of all variates may differ from that of the criterion. Depending on the conditional structure of the relative sequences and the timescale of investigation, higher or lower MCSE may be more desirable or acceptable.
For the use dates of artifact type production, use, and deposition, see the gibbs_ad_type function.
Value
A list object of class marginals which contains the following:
-
depositionAlistof samples from the marginal density of each context's depositional date. -
externalsAlistof samples of the marginal density of each constraint (t.p.q. and t.a.q.]), as conditioned upon the occurrence of other depositional -
productionIf afindsobject has been input, samples of the marginal density of the production date of finds types will be included in the output. If types are attested in trimmed contexts, -
mcseThe Monte Carlo standard errors (MCSE) of the random variates (fixed t.p./a.q. will have a MCSE of 0.)
References
Bronk Ramsey C (2009).
“Bayesian Analysis of Radiocarbon Dates.”
Radiocarbon, 51, 337–360.
doi:10.1017/s0033822200033865.
Buck CE, Cavanagh WG, Litton CD (1996).
Bayesian Approach to Interpreting Archaeological Data.
John Wiley and Sons, Chichester.
Buck CE, Christen JA, James GN (1999).
“BCal: An On-line Bayesian Radiocarbon Calibration Tool.”
Internet Archaeology, 7.
doi:10.11141/ia.7.1, https://intarch.ac.uk/journal/issue7/buck/.
Flegal JM, Haran M, Jones GL (2008).
“Markov Chain Monte Carlo: Can We Trust the Third Significant Figure?”
Statistical Science, 23, 250–260.
doi:10.1214/08-STS257.
Jones GL, Haran M, Caffo BS, Neath R (2006).
“Fixed-Width Output Analysis for Markov Chain Monte Carlo.”
Journal of the American Statistical Association, 101, 1537–1547.
doi:10.1198/016214506000000492.
Examples
x <- events("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- events("B", "D", "G", "H", "K")
z <- events("F", "K", "L", "M")
contexts <- sequences(x, y, z)
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
# seq(37, 41, length = 100) is equivalent in concept to runif(100, 37, 41))
destr <- absolute(id = "destr", assoc = "J", type = NULL, samples = 79)
tpq_info <- constraints(coin1, coin2)
taq_info <- constraints(destr)
result <- gibbs_ad(contexts, tpq = tpq_info, taq = taq_info)
Gibbs Sampler for Archaeological Dates: Artifact Types
Description
Estimate a densities for the production, use, and deposition dates of an artifact or artifact type. Multiple artifacts and types can be given, which will be pooled into a single type. For example, one can input several individual finds via their id number as comprising a type, or multiple (sub)types/classes as a single type, (e.g., "MGS V amphora", "MGS VI amphora", "MGS V/VI amphora" to construct one group). Depending on whether one is using id numbers or type(s), the id or type argument is used, which takes a vector of the entries' names. The gibbs_ad_type function works on the basis of the presence/absence of types in contexts, sampling a use date between the production and deposition. The stipulation of a rule to determine production dates (naive or earliest) is required.
Usage
gibbs_ad_type(
sequences,
finds = NULL,
id = NULL,
type = NULL,
type_name = NULL,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
trim = TRUE,
rule = "naive",
quiet = FALSE
)
## S3 method for class 'sequences'
gibbs_ad_type(
sequences,
finds = NULL,
id = NULL,
type = NULL,
type_name = NULL,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
trim = TRUE,
rule = "naive",
quiet = FALSE
)
Arguments
sequences |
A |
finds |
An |
id |
A vector of the |
type |
A vector of one or more types to estimate a use density for. Must contain a value if |
type_name |
A customized label for the type (e.g., if one is selecting via |
max_samples |
Maximum number of samples to run. Default is |
size |
The number of samples to take on each iteration of the main Gibbs sampler. Default is |
mcse_crit |
Criterion for the Monte Carlo standard error to stop the Gibbs sampler. Only the MCSE of the use date is used as a stopping rule. |
tpq |
A |
taq |
A |
alpha_ |
An initial t.p.q. to limit any elements which may occur before the first provided t.p.q. Default is |
omega_ |
A final t.a.q. to limit any elements which may occur after the after the last provided t.a.q. Default is |
trim |
A logical value to determine whether elements that occur before the first t.p.q. and after the last t.a.q. should be omitted from the results (i.e., to "trim" elements at the ends of the sequence, whose marginal densities depend on the selection of |
rule |
The rule for computing an estimated date of production of a find-type, either |
quiet |
Whether to supress messages/progress output while function is running. Default is |
Details
See gibbs_ad for information on consistent batch means and Monte Carlo standard error, which are used to determined convergence for the use date.
Value
A list of class type_marginals of the density of a use date, conditional upon production and depositional dates.
Examples
x <- events("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- events("B", "D", "G", "H", "K")
z <- events("F", "K", "L", "M")
contexts <- sequences(x, y, z)
f1 <- finds(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- finds(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- finds(id = "find03", assoc = "G", type = c("type1", "form1"), residual = TRUE)
f4 <- finds(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- finds(id = "find05", assoc = "I", type = "type2")
f6 <- finds(id = "find06", assoc = "H", type = NULL)
artifacts <- assemblage(f1, f2, f3, f4, f5, f6)
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
destr <- absolute(id = "destr", assoc = "J", type = NULL, samples = 79)
tpq_info <- constraints(coin1, coin2)
taq_info <- constraints(destr)
# use dates by specifying ids
gibbs_ad_type(contexts, artifacts, id = c("find04", "find05"),
max_samples = 2000, mcse_crit = 2, tpq = tpq_info, taq = taq_info)
# use dates by specifying types
gibbs_ad_type(contexts, artifacts, type = "type1",
max_samples = 2000, mcse_crit = 2, tpq = tpq_info, taq = taq_info)
Histogram of Marginal Densities
Description
Wrapper around hist to plot density histograms for select marginal densities (up to 12) in a single plot, from the results of gibbs_ad, or to plot density histograms of the production, deposition, and use of a type, from the results of gibbs_ad_type.
Usage
histogram(
x,
events = NULL,
aspect = c("production", "use", "deposition"),
breaks = "Freedman-Diaconis",
xlim = NULL,
ylim = NULL,
xlab = "Year",
palette = NULL,
opacity = 1,
legend_pos = "topright"
)
## S3 method for class 'marginals'
histogram(
x,
events = NULL,
aspect = NULL,
breaks = "Freedman-Diaconis",
xlim = NULL,
ylim = NULL,
xlab = "Year",
palette = NULL,
opacity = 1,
legend_pos = "topright"
)
## S3 method for class 'type_marginals'
histogram(
x,
events = NULL,
aspect = c("production", "use", "deposition"),
breaks = "Freedman-Diaconis",
xlim = NULL,
ylim = NULL,
xlab = "Year",
palette = NULL,
opacity = 0.5,
legend_pos = "topright"
)
Arguments
x |
A |
events |
If plotting a |
aspect |
If plotting a |
breaks |
The number or method of breaks in the histogram. Default is |
xlim |
The limits of the x-axis. Default is set to the min/max values of all samples. |
ylim |
The limits of the y-axis. This may need to be adjusted if densities have an extremely narrow interval. |
xlab |
Label for the x-axis. Default is |
palette |
A vector providing the color palette of the histogram. The default is |
opacity |
The opacity/transparency of the histograms for visualizing overlapping events, a value between 0 and 1 (default). |
legend_pos |
The position of the legend in the plot. Default is |
Details
See also also tidy_marginals for exporting the results of these functions into tidy data frame for custom plotting in e.g., ggplot2.
Value
A density histogram of the selected events/aspects.
A density histogram of the selected events/aspect.
Examples
x <- events("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- events("B", "D", "G", "H", "K")
z <- events("F", "K", "L", "M")
contexts <- sequences(x, y, z)
f1 <- finds(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- finds(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- finds(id = "find03", assoc = "G", type = c("type1", "form1"), residual = TRUE)
f4 <- finds(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- finds(id = "find05", assoc = "I", type = "type2")
f6 <- finds(id = "find06", assoc = "H", type = NULL)
artifacts <- assemblage(f1, f2, f3, f4, f5, f6)
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
destr <- absolute(id = "destr", assoc = "J", type = NULL, samples = 79)
tpq_info <- constraints(coin1, coin2)
taq_info <- constraints(destr)
result <- gibbs_ad(contexts, tpq = tpq_info, taq = taq_info)
# deposition of "B"
histogram(result, "B")
# deposition of "coin2" and deposition of "G"
histogram(result, c("coin2", "G"), opacity = 0.5)
# production, use, and deposition of "type1"
result_type1 <- gibbs_ad_type(contexts, artifacts, type = "type1",
max_samples = 3000, mcse_crit = 2)
histogram(result_type1)
Ids of Types
Description
Given a list object of finds (with keys of id, assoc, type in each entry), return a vector of the id elements that belong to one or more specified type.
Usage
ids_of_types(input, type = NULL)
## S3 method for class 'assemblage'
ids_of_types(input, type = NULL)
Arguments
input |
An |
type |
A character vector or element |
Value
A character vector of ids within a list object of finds class,
Examples
f1 <- finds(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- finds(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- finds(id = "find03", assoc = "G", type = c("type1", "form1"))
f4 <- finds(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- finds(id = "find05", assoc = "I", type = "type2")
f6 <- finds(id = "find06", assoc = "H", type = NULL)
artifacts <- assemblage(f1, f2, f3, f4, f5, f6)
ids_of_types(artifacts, type = "type1")
ids_of_types(artifacts, type = c("type1", "type2"))
Mean Squared Displacement of Events
Description
Computes the mean squared displacement (MSD) of all events contained in the relative sequences and absolute constraints used in the execution of gibbs_ad. MSD is not intended for finds, in their production, use, and depositional dates, since these aspects are themselves contingent upon the variates of relative/absolute events.
Usage
msd(
marginalized,
sequences,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
quiet = FALSE
)
## S3 method for class 'marginals'
msd(
marginalized,
sequences,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
quiet = FALSE
)
Arguments
marginalized |
An object of class |
sequences |
A |
max_samples |
Maximum number of samples to run. Default is |
size |
The number of samples to take on each iteration of the main Gibbs sampler. Default is |
mcse_crit |
Criterion for the Monte Carlo standard error to stop the Gibbs sampler. A higher MCSE is recommended for situations with a higher number of events in order to reduce computational time. |
tpq |
A |
taq |
A |
alpha_ |
An initial t.p.q. to limit any elements which may occur before the first provided t.p.q. Default is |
omega_ |
A final t.a.q. to limit any elements which may occur after the after the last provided t.a.q. Default is |
quiet |
Whether to supress messages/progress output while function is running. Default is |
Details
The MSD entails the following jackknife/leave-one-out style routine:
Each event is omitted from all relative and absolute sequences, and the function
gibbs_adis re-run to compute a "jackknifed" Monte Carlo mean for that event.The squared difference of this jackknifed Monte Carlo mean and the original is then computed as its squared "displacement" in time.
The mean of the squared displacements of all events is then computed and attributed to the omitted event.
If an event has a low MSD, it bears a low impact on the rest of the events within the full joint conditional density. If it is has a high MSD, other events depend heavily upon its inclusion in the full joint density.
Trimming is not implemented in the computation of MSD, and so attention should be paid to the selection of alpha_ and omega_, which should be reported. This is owing to the way in which, if an absolute constraint (tpq or taq) is omitted that happens to be an earliest or latest bounding event, there still needs to be earliest and latest thresholds in place.
This function is fairly computationally intensive and thus a lower value of max_samples and a higher value of mcse_crit may be warranted.
Value
Output is a list containing a data frame MSD_stats giving the mean MC date, the MCSE, the MSD, the variance of the squared displacements (not the standard error), and sample size, as well as a vector bounds of the values of alpha_ and omega_.
Examples
x <- events("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- events("B", "D", "G", "H", "K")
z <- events("F", "K", "L", "M")
contexts <- sequences(x, y, z)
f1 <- finds(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- finds(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- finds(id = "find03", assoc = "G", type = c("type1", "form1"))
f4 <- finds(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- finds(id = "find05", assoc = "I", type = "type2")
f6 <- finds(id = "find06", assoc = "H", type = NULL)
artifacts <- assemblage(f1, f2, f3, f4, f5, f6)
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
destr <- absolute(id = "destr", assoc = "J", type = NULL, samples = 79)
tpq_info <- constraints(coin1, coin2)
taq_info <- constraints(destr)
result <- gibbs_ad(contexts, tpq = tpq_info, taq = taq_info)
result_msd <- msd(result, contexts, max_samples = 5000,
mcse_crit = 2, tpq = tpq_info, taq = taq_info)
Quae Antea
Description
For a list of multiple partial sequences of events objects, generates a list which, for each element, giving the elements that occur before it ("quae antea"). This is analogous to a recursive trace through all partial sequences from right to left. An element "alpha" is added to all sets to avoid empty vectors. See also quae_postea.
Usage
quae_antea(...)
## S3 method for class 'events'
quae_antea(...)
## S3 method for class 'list'
quae_antea(...)
## S3 method for class 'sequences'
quae_antea(...)
Arguments
... |
Objects of class |
Value
A list of vector objects, which contain the elements that occur before any one given element in the input sequences.
Examples
x <- events("A", "B", "C")
y <- events("B", "D", "E", "C", "F")
z <- events("C", "G")
quae_antea(x, y, z)
Quae Postea
Description
For a list of multiple partial sequences (of vector objects), generate another list which, for each element, gives all elements that occur after it ("quae postea"). This is analogous to a recursive trace through all partial sequences from left to right. A final element "omega" is added to all sets to avoid empty vectors. See also quae_antea.
Usage
quae_postea(...)
## S3 method for class 'events'
quae_postea(...)
## S3 method for class 'list'
quae_postea(...)
## S3 method for class 'sequences'
quae_postea(...)
Arguments
... |
Objects of class |
Value
A list of vector objects, which contain the elements that occur after any one given element in the input sequences.
Examples
x <- events("A", "B", "C")
y <- events("B", "D", "E", "C", "F")
z <- events("C", "G")
quae_postea(x)
quae_postea(x, y, z)
a <- sequences(x, y, z)
quae_postea(a)
Adjust Sequence to Target
Description
Given an "input" sequence of elements and another "target" sequence that contains fewer elements in a different order, shift the order of the input sequence to match that of the target, keeping all other elements as proximate to one another as possible. This adjusted ranking is accomplished using piecewise linear interpolation between joint elements ranks. That is, joint rankings are plotted, with input rankings along the x axis and target rankings on the y axis. Remaining rankings in the input sequence are assigned a ranking of y based on the piecewise linear function between joint rankings. If the rank order of elements in the target are identical to those in the input, the result is identical to the input. A minimum number of three joint elements in both the input and target are required.
Usage
seq_adj(input, target)
## S3 method for class 'events'
seq_adj(input, target)
Arguments
input |
An |
target |
An |
Value
An events object of the adjusted sequence.
Examples
x <- events("A", "B", "C", "D", "E", "F", "G", "H", "I", "J") # the input sequence of events
y <- events("D", "A", "J") # the target sequence of events
seq_adj(x, y)
Sequence Diagnostic
Description
If the creation of a sequences object has failed, this function checks events objects for instances of disagreement, by proceeding through all events in order, agglomerating them and checking for sequence validty. Hence, there are events which are assured to be valid, these should be placed first in the input to seq_diag. If there is no information about the validity of the events, the shuffle option can be set to TRUE, which will randomly permute the order in which events are agglomerated.
Usage
seq_diag(..., shuffle = FALSE)
## S3 method for class 'events'
seq_diag(..., shuffle = FALSE)
## S3 method for class 'list'
seq_diag(..., shuffle = FALSE)
Arguments
... |
Objects of |
shuffle |
Whether to randomly permute the order of the |
Value
A sequences object.
Examples
u <- events("A", "D", "E")
v <- events("E", "D")
w <- events("B", "F", "C")
x <- events("A", "B", "C", "D", "E")
seq_diag(u, v, w, x)
a <- list(u, v, w, x)
seq_diag(a)
Create a Sequences Object
Description
Analogous to the list function, a sequences object contains multiple events objects.
Usage
sequences(...)
## S3 method for class 'events'
sequences(...)
## S3 method for class 'list'
sequences(...)
Arguments
... |
objects of |
Value
A sequences object.
Examples
x <- events("A", "B", "C", "D", "E")
y <- events("B", "D", "F")
z <- events("A", "C", "F", "G")
sequences(x, y, z)
a <- list(x, y, z)
sequences(a)
Squared Displacement for a Target Event
Description
Computes the squared displacement for a target event within the joint conditional density, estimating how much the omission of every other event will change the date of the target. See also msd. If the target event is a find or type, the displacement of the use date is used, since use is contingent upon both production and deposition.
Usage
sq_disp(
marginalized,
target = NULL,
sequences,
finds = NULL,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
rule = "naive",
quiet = FALSE
)
## S3 method for class 'marginals'
sq_disp(
marginalized,
target = NULL,
sequences,
finds = NULL,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
rule = NULL,
quiet = FALSE
)
## S3 method for class 'type_marginals'
sq_disp(
marginalized,
target = NULL,
sequences,
finds = NULL,
max_samples = 10^5,
size = 10^3,
mcse_crit = 0.5,
tpq = NULL,
taq = NULL,
alpha_ = -5000,
omega_ = 1950,
rule = "naive",
quiet = FALSE
)
Arguments
marginalized |
The results of |
target |
The target event (any event for which to estimate squared displacement. If using the results of |
sequences |
A |
finds |
Optional. A |
max_samples |
Maximum number of samples to run. Default is |
size |
The number of samples to take on each iteration of the main Gibbs sampler. Default is |
mcse_crit |
Criterion for the Monte Carlo standard error to stop the Gibbs sampler. A higher MCSE is recommended for situations with a higher number of events in order to reduce computational time. |
tpq |
A |
taq |
A |
alpha_ |
An initial t.p.q. to limit any elements which may occur before the first provided t.p.q. Default is |
omega_ |
A final t.a.q. to limit any elements which may occur after the after the last provided t.a.q. Default is |
rule |
The rule for computing an estimated date of production, if using an artifact type as a target date. See |
quiet |
Whether to supress messages/progress output while function is running. Default is |
Details
Displacement is computed via the following jackknife/leave-one-out-style routine:
Each event, excluding the target event itself, is omitted from all relative and absolute sequences, and the function
gibbs_adis re-run to compute a "jackknifed" Monte Carlo mean for the target event.The squared difference of this jackknifed Monte Carlo mean and the original is then computed as its squared "displacement" in time.
If an event has a low squared displacement, it has a low impact on the dating of the target event. If it is has a high squared displacement, the target event's date depends heavily upon its inclusion in the full joint density.
Trimming is not implemented in the estimation of squared displacement, and so attention should be paid to the selection of alpha_ and omega_, and reported. This is owing to the way in which, if an absolute constraint (tpq or taq) is omitted that happens to be an earliest or latest bounding event, there still needs to be earliest and latest thresholds in place.
This function is fairly computationally intensive, and so a lower value of max_samples or higher value of mcse_crit may be warranted.
Value
Output is a list containing a data frame sq_disp giving the displacement with respect to all other events and a vector bounds of the values of alpha_ and omega_.
Examples
x <- events("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- events("B", "D", "G", "H", "K")
z <- events("F", "K", "L", "M")
contexts <- sequences(x, y, z)
f1 <- finds(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- finds(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- finds(id = "find03", assoc = "G", type = c("type1", "form1"))
f4 <- finds(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- finds(id = "find05", assoc = "I", type = "type2")
f6 <- finds(id = "find06", assoc = "H", type = NULL)
artifacts <- assemblage(f1, f2, f3, f4, f5, f6)
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
destr <- absolute(id = "destr", assoc = "J", type = NULL, samples = 79)
tpq_info <- constraints(coin1, coin2)
taq_info <- constraints(destr)
result <- gibbs_ad(contexts, tpq = tpq_info, taq = taq_info)
# max_samples lowered and msce_crit raised for examples
# squared displacement for depositional context "E"
E_sqdisp <- sq_disp(result, target = "E", sequences = contexts,
max_samples = 3000, mcse_crit = 2, tpq = tpq_info, taq = taq_info)
result_type1 <- gibbs_ad_type(contexts, finds = artifacts, type = "type1",
tpq = tpq_info, taq = taq_info)
# squared displacement for production of artifact type "type1"
type1_sqdisp <- sq_disp(result_type1, sequences = contexts, finds = artifacts,
max_samples = 3000, mcse_crit = 2, tpq = tpq_info, taq = taq_info)
Synthetic Ranking
Description
Using a sequences object of two or more partial sequences, all of which observe the same order of elements, create a single "synthetic" ranking. This is accomplished by counting the total number of elements after running a recursive trace through all partial sequences (via quae_postea). If partial sequences are inconsistent in their rankings, a NULL value is returned.
Usage
synth_rank(obj, ties = "average")
## S3 method for class 'sequences'
synth_rank(obj, ties = "average")
Arguments
obj |
A |
ties |
The way in which ties are handled per the |
Value
An events object containing the synthesized ranking.
Examples
x <- events("A", "B", "C", "D", "E")
y <- events("B", "D", "F", "E")
a <- sequences(x, y)
synth_rank(a)
Convert Marginals to Tidy (Molten) Data Frame
Description
Takes the results of gibbs_ad or gibbs_ad_type and "melts" the list into a tidy data frame (Wickham 2014). Each row of the molten data frame will contain the index of the Monte Carlo sample, the sample itself, and then the event name.
Usage
tidy_marginals(input)
## S3 method for class 'marginals'
tidy_marginals(input)
## S3 method for class 'type_marginals'
tidy_marginals(input)
Arguments
input |
An object of class |
Value
A data frame giving the MC sampling index (idx), the sample (year), and the event (event).
References
Wickham H (2014). “Tidy Data.” Journal of Statistical Software, 59, 1–23. doi:10.18637/jss.v059.i10.
Examples
x <- events("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- events("B", "D", "G", "H", "K")
z <- events("F", "K", "L", "M")
contexts <- sequences(x, y, z)
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
destr <- absolute(id = "destr", assoc = "J", type = NULL, samples = 79)
tpq_info <- constraints(coin1, coin2)
taq_info <- constraints(destr)
result <- gibbs_ad(contexts, tpq = tpq_info, taq = taq_info)
tidy_marginals(result)
Traceplot of Gibbs Samples
Description
Wrapper around plot to make a traceplot of Gibbs samples from gibbs_ad. See histogram. Maximum number of simultaneous events to display is 12. for plotting a density histogram of events.
Usage
traceplot(
x,
events = NULL,
xlim = NULL,
ylim = NULL,
xlab = "Index",
ylab = "Year",
palette = NULL,
opacity = 1,
legend_pos = "topright"
)
## S3 method for class 'marginals'
traceplot(
x,
events = NULL,
xlim = NULL,
ylim = NULL,
xlab = "Index",
ylab = "Year",
palette = NULL,
opacity = 1,
legend_pos = "topright"
)
Arguments
x |
A |
events |
A vector or element of the event names to plot. Maximum number of events is 12. |
xlim |
The limits of the x-axis (optional). |
ylim |
The limits of the y-axis (optional). |
xlab |
Label for the y-axis. Default is |
ylab |
Label for the y-axis. Default is |
palette |
A vector providing the color palette of the histogram. The default is |
opacity |
The opacity/transparency of the traceplot, if visualizing overlapping events. A value between 0 and 1 (default). |
legend_pos |
The position of the legend in the plot. Default is |
Details
See also tidy_marginals for exporting the results of these functions into tidy data frame for custom plotting in e.g., ggplot2.
Value
A traceplot of the Gibbs samples of the selected events.
Examples
x <- events("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- events("B", "D", "G", "H", "K")
z <- events("F", "K", "L", "M")
contexts <- sequences(x, y, z)
# external constraints
coin1 <- absolute(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- absolute(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
destr <- absolute(id = "destr", assoc = "J", type = NULL, samples = 79)
tpq_info <- constraints(coin1, coin2)
taq_info <- constraints(destr)
result <- gibbs_ad(contexts, tpq = tpq_info, taq = taq_info)
traceplot(result, "B")
traceplot(result, c("coin1", "B", "H"), opacity = 0.5)