autorun_BayLum: autorun_BayLum

View source: R/autorun_BayLum.R

autorun_BayLumR Documentation

autorun_BayLum

Description

autorun_BayLum() takes the output of "Generate_DataFile()", "Generate_DataFile_MG()" or "Create_DataFile()" - which may have been built on several samples - and runs BayLum on each sample individually.
BayLum is run until the Rubin-Gelman statistics are below 1.050 for "A", "D" and "sD" parameters for a sample. If a particular run fails to converge, the function will proceed to double the number of "Iter" used. The doubling proceeds until convergence is reached.
The function then stitches together the "A"-parameter MCMC-samples for each sample into one csv-file (this is the input for Age-Depth model of the ArchaeoPhases-package). The same is true for the "D"-parameter.

Usage

autorun_BayLum(
  DataFile,
  SampleNames,
  BinPerSample,
  csv_name,
  Iter = 10000,
  create_new_files = TRUE,
  Origin_fit = TRUE,
  LIN_fit = FALSE,
  distribution = "gaussian",
  PriorAge = c(1, 100)
)

Arguments

DataFile

The output of "Generate_DataFile()", "Generate_DataFile_MG" or "Create_DataFile" of the BayLum R-package.

SampleNames

A vector of names to be attached to attached to each sample.

BinPerSample

A vector of numbers indicating how many binx-files exist for samples (in order of samples structered by the DataFile-object). BinPerSample = c(1,2,1) would indicate that sample 1 and sample 3 have 1 binx-file each. Sample 2 as 2 binx-files.

csv_name

The prefix-label to put on each produced csv-file. csv_name = "example" would create csv-files named: "example_MCMC_A.csv" and "example_MCMC_D.csv".

Iter

(with default = 10000) The number of sampling iterations that the MCMC should run for (an equal number of burn-in iterations is defined).

create_new_files

(with default = TRUE) Whether all new MCMC csv-files should be created or not. If "FALSE", the function will built on presumably already existing csv_files with labels that match csv_name and the suffix. This could be useful secondary runs are needed (for example if new samples are added after having run this function already)

Origin_fit

(with default = TRUE) Should DRC-fits be forced through zero?

LIN_fit

(with default = FALSE) Should DRC-fits be a saturating exponential plus a linear component?

distribution

(with default = gaussian) Which dose-dispersion model within BayLum to use? (possible are "gaussian", "lognormal_A", "lognormal_M" and "cauchy")

PriorAge

= (with default = c(1, 100)) The prior for the age. User can only specify one interval which is forced on all samples. So user must consider the most extreme samples. Since samples are run one at a time, this should not have major ramifications on convergence-time.

Value

This function returns a summary of samples that have been run along with a status-marker. More importantly, csv-files are written - one for the "A" parameter, one for the "D" parameter - in which converged output MCMC samples are sticthed together in the original sample order dictated by the DataFile-input. Credible intervals can then be computed from them or they can be used in Age-depth models. A csv-file with Rubin-Gelman statistics for all samples is also produced.


IMHarly/justapackage documentation built on March 25, 2024, 8:10 p.m.