R/chrono_Gauss.R

Defines functions chrono_Gauss

Documented in chrono_Gauss

#' Bayesian chronologies of Gaussian dates.
#'
#' @author Anne Philippe, Marie-Anne Vibet
#'
#' @references
#'
#' @examples
#'
#' @export


chrono_Gauss <- function(M, s, refYear=NULL, studyPeriodMin, studyPeriodMax, 
                              numberChains = 2, numberAdapt = 10000, numberUpdate = 10000, 
                              variable.names = c('theta'), numberSample = 50000, thin = 10){
  
  # Checking inputs
  if(length(M)!=length(s)) stop("Vector of measurements and vector of errors should have the same length")

  if( !is.null(refYear) ){
    if(length(M)!=length(refYear)) stop("Vector of measurements and vector of refYear should have the same length")
  }
  
  # Conversion in BC/AD format
  if (!is.null(refYear)){
    M = refYear - M
  }
  
  # Bayesian model
  model.file <- system.file(package="ArchaeoChron", "model", "chrono_Gauss.txt")    
  
  print('Modeling done with JAGS following')  
  jags <- jags.model(file = model.file, data = list('Nbobs' = length(M),'M' = M,'s'=s, 'ta'=studyPeriodMin,'tb'=studyPeriodMax),
                     n.chains = numberChains, n.adapt = numberAdapt)
  print('Update period')
  update(object = jags, n.iter = numberUpdate)
  print('Acquire period')
  MCMCSample = coda.samples(model = jags, variable.names = variable.names, n.iter = numberSample, thin =thin)
  
  return(MCMCSample)
  
}

Try the ArchaeoChron package in your browser

Any scripts or data that you put into this service are public.

ArchaeoChron documentation built on May 2, 2019, 9:13 a.m.