run_jags: Run parallel MCMC sampling using JAGS.

Description Usage Arguments Value Author(s)

View source: R/run_jags.R

Description

Run parallel MCMC sampling using JAGS.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
run_jags(
  data,
  jags_code,
  pars,
  ST,
  cores,
  sample,
  n.chains,
  n.iter,
  n.adapt,
  inits
)

Arguments

data

Data.frame or tibble in long format.

jags_code

A string. JAGS model, usually returned by make_jagscode().

pars

Character vector of parameters to save/monitor.

ST

A segment table (tibble), returned by get_segment_table. Only really used when the model contains varying effects.

cores

Positive integer or "all". Number of cores.

  • 1: serial sampling (Default). options(mc.cores = 3) will dominate cores = 1 but not larger values of cores.

  • >1: parallel sampling on this number of cores. Ideally set chains to the same value. Note: cores > 1 takes a few extra seconds the first time it's called but subsequent calls will start sampling immediately.

  • "all": use all cores but one and sets chains to the same value. This is a convenient way to maximally use your computer's power.

sample

One of

  • "post" (default): Sample the posterior.

  • "prior": Sample only the prior. Plots, summaries, etc. will use the prior. This is useful for prior predictive checks.

  • "both": Sample both prior and posterior. Plots, summaries, etc. will default to using the posterior. The prior only has effect when doing Savage-Dickey density ratios in hypothesis.

  • "none" or FALSE: Do not sample. Returns an mcpfit object without sample. This is useful if you only want to check prior strings (fit$prior), the JAGS model (fit$jags_code), etc.

n.chains

the number of parallel chains for the model

n.iter

number of iterations to monitor

n.adapt

the number of iterations for adaptation. See adapt for details. If n.adapt = 0 then no adaptation takes place.

inits

A list if initial values for the parameters. This can be useful if a model fails to converge. Read more in jags.model. Defaults to NULL, i.e., no inits.

Value

'mcmc.list“

Author(s)

Jonas Kristoffer Lindeløv jonas@lindeloev.dk


mcp documentation built on Aug. 3, 2020, 5:07 p.m.