Skip to contents

Fit errors-in-variables models with JAGS

Usage

run_mod(
  dat,
  model = "slr",
  EIV = TRUE,
  BP_scale = FALSE,
  n_cp = 1,
  igp_smooth = 0.2,
  iter = 5000,
  burnin = 1000,
  thin = 4,
  scale_factor_x = 1,
  scale_factor_y = 1
)

Arguments

dat

Input data with columns x,x_err,y,y_err

model

The model to run. Choose from slr, cp, gp, igp

EIV

Use EIV framework. Defaults to TRUE

BP_scale

Present the data as Before Present (BP). Defaults to FALSE.

n_cp

Number of change points if model = "cp" is chosen. Can choose from 1,2,3,4.

igp_smooth

Informs prior for the smoothness (correlation) parameter if model = "igp" is chosen. Choose a value between 0 and 1. Closer to 1 will increase smoothness.

iter

MCMC iterations

burnin

MCMC burnin

thin

MCMC thinning

scale_factor_x

value to divide the predictor (x) by to change the scale. 1 will result in no change. 1000 is recommended if x is years.

scale_factor_y

value to divide the response (y) by to change the scale. 1 will result in no change.

Value

List with data, JAGS input data, model output and the name of the model file.

Examples

dat <- sim_slr(n_sim = 30)
mod <- run_mod(dat, model = "slr")
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 60
#>    Unobserved stochastic nodes: 33
#>    Total graph size: 380
#> 
#> Initializing model
#> 
#> No convergence issues detected