parallel_stan {varian}R Documentation

Wrapper for the stan function to parallelize chains

Description

This funcntion takes Stan model code, compiles the Stan model, and then runs multiple chains in parallel.

Usage

parallel_stan(model_code, standata, totaliter, warmup, thin = 1, chains, cl,
  cores, seeds, modelfit, verbose = FALSE, pars = NA, sample_file = NA,
  diagnostic_file = NA, init = "random", ...)

Arguments

model_code

A character string of Stan code

standata

A data list suitable for Stan for the model given

totaliter

The total number of iterations for inference. Note that the total number of iterations is automatically distributed across chains.

warmup

How many warmup iterations should be used? Note that every chain will use the same number of warmups and these will be added on top of the total iterations for each chain.

thin

The thin used, default to 1 indicating that all samples be saved.

chains

The number of independent chains to run.

cl

(optional) The name of a cluster to use to run the chains. If not specified, the function will make a new cluster.

cores

(optional) If the cl argument is not used, this specifies the number of cores to make on the new cluster. If both cl and cores are missing, defaults to the minimum of the number of chains specified or the number of cores available on the machine.

seeds

(optional) A vector of random seeds the same length as the number of independent chains being run, to make results replicable. If missing, random seeds will be generated and stored for reference in the output.

modelfit

(optional) A compiled Stan model, if available, saves compiling model_code.

verbose

A logical whether to print verbose output (defaults to FALSE)

pars

Parameter names from Stan to store

sample_file

The sample file for Stan

diagnostic_file

The diagnostic file for Stan

init

A character string (“random”) or a named list of starting values.

...

Additional arguments, not currently used.

Value

a named list with three elements, the results, compiled Stan model, and the random seeds

Author(s)

Joshua F. Wiley <josh@elkhartgroup.com>

Examples

# Make me!

[Package varian version 0.2.2 Index]