sma_analyse: Analyse data for a simulation study

View source: R/simanalyse-analyse.R

sma_analyseR Documentation

Analyse data for a simulation study

Description

Analyse data for a simulation study. Allows results to be written to files.

Usage

sma_analyse(
  sims,
  code,
  code.add = "",
  code.values = NULL,
  monitor = ".*",
  inits = list(),
  mode = sma_set_mode("report"),
  deviance = TRUE,
  progress = FALSE,
  options = furrr::furrr_options(seed = TRUE)
)

Arguments

sims

An nlists or nlist object of the data (or list that can be coerced to nlist or nlists).

code

A string of code to analyze the data. JAGS code must not be in a data or model block.

code.add

A string of code to add at the end of code before analysing the data. This is useful for adding priors to the likelihood.

code.values

A character vector to replace all instances of "?" in the model. This is useful for varying choices of distributions, e.g. for assessing sensitivity to the choice of priors.

monitor

A character vector (or regular expression if a string) specifying the names of the stochastic nodes to output from the analysis. By default all stochastic nodes are included.

inits

A list or a function. Initial values for the MCMC chains. If specifying a function, it should either have no arguments, or have a single argument named chain. In the latter case, the supplied function is called with the chain number as argument. In this way, initial values may be generated that depend systematically on the chain number.

mode

A list obtained from sma_set_mode which sets the parameters of the mcmc sampling.

deviance

A flag. Indicates whether to monitor deviance for future DIC calculation.

progress

A flag specifying whether to print a progress bar.

options

The future specific options to use with the workers.

Value

A flag.

Examples

 set.seed(10L)
 code <- "a ~ dnorm(mu,1)"
 sims <- sims::sims_simulate(code, parameters = nlist(mu=0), nsims=2)
 prior = "mu ~ dunif(-3,3)"
 result <- sma_analyse(sims=sims,
                                       code = code,
                                       code.add = prior,
                                       mode=sma_set_mode("quick"),
                                       monitor = "mu")

audrey-b/simanalyse documentation built on May 20, 2022, 7:45 p.m.