simulateCalendarDates | R Documentation |
Randomly samples calendar dates from a model, including dates slightly outside the model date range to avoid edge effects
simulateCalendarDates(model, n)
model |
A data frame including columns 'year' and 'pdf' |
n |
The number of dates to sample. |
Samples n random calendar dates from a model pdf. This model must be defined in terms of a PDF vector and the corresponding calendar years. This can be provided at any preferred temporal resolution. For example, an exponential model can be provided with the PDF in annual intervals, whilst CPL model needs only the hinge points. convertPars
will convert parameters into the required model format.
Returns a vector of calendar dates
# under a uniform model
model <- convertPars(pars=NA, years=5000:6000,type='uniform')
sims <- simulateCalendarDates(model, 1000)
range(sims)
# simulate under an exponential model
model <- convertPars(pars=0.001, years=5000:6000,type='exp')
sims <- simulateCalendarDates(model, 1000)
range(sims)
# under a CPL model
model <- convertPars(pars=runif(5), years=5000:6000,type='CPL')
sims <- simulateCalendarDates(model, 1000)
range(sims)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.