smc_analyse: Analyse Datasets for multiple cases/scenarios using Bayesian...

Description Usage Arguments Details See Also Examples

View source: R/simcases-analyse.R

Description

Analyse Datasets for multiple cases/scenarios using Bayesian methods. Results are saved to disk.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
smc_analyse(
  models,
  cases,
  code = "",
  code.add = "",
  code.values = NULL,
  monitor = ".*",
  inits = list(),
  mode = sma_set_mode("report"),
  deviance = TRUE,
  path = ".",
  progress = FALSE,
  options = furrr::future_options(seed = TRUE),
  environment = parent.frame(),
  fun = function(x) read.table(text = gsub(";|,| |:|\t|\\||&|~", "\t",
    readLines(textConnection(x))), header = TRUE),
  ...
)

Arguments

models

A data frame or an object that becomes a data frame when fun is applied. The data frame contains character strings that refer to objects defined within environment. Each row defines a model. The header may contain: code, code.add, code.values, monitor, inits, mode and/or deviance.

cases

A data frame or an object that becomes a data frame when fun is applied. The header must be "sims analyse" and the data frame contains integers (1,2,3,...) that refer to specific combinations of data and analyses. Each row is a different case/scenario.

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. To be used only if not specified in models. 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 containing the 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 of mcmc parameters set using [simanalyse::sma_set_mode()].

deviance

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

path

A string specifying the path to the directory.

progress

A flag specifying whether to print a progress bar.

options

The future specific options to use with the workers.

environment

The environment in which the objects described in cases were defined.

fun

A function to convert models and cases to data frames.

...

Unused.

Details

The arguments code, code.add, code.values, monitor, inits, mode and deviance will only be used if not specified within models.

See Also

[simanalyse::sma_set_mode()]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
normal <- "a ~ dnorm(0, 1/sigma^2)"
sigma1 <- list(sigma=1)
sigma2 <- list(sigma=2)
all <- ".*"
models_sims <- "code   constants
                normal sigma1
                normal sigma2"
smc_simulate(models = models_sims,
                  path = tempdir(), 
                  exists = NA, 
                  ask = FALSE,
                  nsims = 2)
models_analysis <- "code   monitor  
                    normal all
                    normal all"
cases <- "sims analyse
          1    1
          2    2"
smc_analyse(models = models_analysis,
                     cases = cases,
                     path = tempdir())

audrey-b/simcases documentation built on July 22, 2020, 6:20 p.m.