Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

CPLparsToHinges

Converts CPL parameters (0 to 1) into hinge (x,y) coordinates (date and pdf) that describe a model


Description

Converts either a vector of parameters, or a matrix of many parameter sets to CPL-model hinges (date and pdf coordinates).

Usage

CPLparsToHinges(pars, years)

Arguments

pars

Either a vector of one parameter set, or a matrix of several parameter sets (one set per row).

years

A vector of years.

Details

The CPL model requires pars to be of odd length, each between 0 and 1. A n-CPL model has \(2n-1\) parameters (\(n-1\) x-parameters and \(n\) y-parameters) that are mapped to \(n+1\) PD coordinates (x,y pairs) using a modified Stick Breaking Dirichlet Process. The first and last x-coordinate are set as \(x_{min}\) and \(x_{max}\), and the remaining internal x-coordinates are converted from their respective x-parameters using the Beta distribution CDF (where \(\alpha = 1\) and \(\beta =\) the number of pieces still to be broken). The y-parameters (between 0 and 1) are converted to y-coordinates in two steps. Firstly, they are mapped from the parameter range (0,1) to the coordinate range (0, \(\infty\)) using the formula \(\frac{1}{(1 - y)^2} - 1\), and the single remaining y-coordinate is set as \(\frac{1}{(1 - 0.5)^2} - 1\). Secondly, they are normalised by the total area under the curve, calculated as the sum of the areas under all \(n\) pieces: \[Area = \sum_{i=1}^{n} (\frac{y_i + y_{i+1}}{2})(x_{i+1} - x_i) \]

Examples

# convert a single random 6-CPL parameter set
	x <- CPLparsToHinges(pars=runif(11), years=5500:7500)

ADMUR

Ancient Demographic Modelling Using Radiocarbon

v1.0.3
GPL-3
Authors
Adrian Timpson [aut, cre] (<https://orcid.org/0000-0003-0292-8729>)
Initial release
2021-03-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.