runStan: Compile and run Stan model

Description Usage Arguments Value

View source: R/runstan.r

Description

Takes data and Stan code created by makeStanmodel and compiles and/or runs the model using Stan

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
runStan(
  model,
  pars = "DEFAULT",
  DIC = TRUE,
  n.iter = 5000,
  n.warmup = floor(n.iter/2),
  thin = 1,
  n.chains = 4,
  inits = "random",
  compilation = TRUE,
  run = TRUE,
  verbose = TRUE,
  comp.model = NULL,
  testing = FALSE
)

Arguments

model

A StanNetModel created by running makeStanmodel

pars

A vector of the character strings giving names of parameters of interest. Default is relative treatment effects, and sigma if a random effects model is used

DIC

Logical indicating if quantities required for calculating DIC will be monitored in MCMC sampling. Default is TRUE.

n.iter

Gives the total number of iterations to run the MCMC chains. Default is 5000.

n.warmup

Gives the number of warmup/burn-in iterations for the MCMC chains. Default is half of n.iter.

thin

The period for saving samples. Default is 1 (samples will be saved for each MCMC sample).

n.chains

The number of different MCMC chains to run. Default is 4.

inits

Named lists of initial values for the MCMC chains. Default "random" which uses random values

compilation

Logical indicating if compilation is needed, default is TRUE. It may be set to FALSE if a compiled Stan model from a previous call to runStan is supplied as comp.model.

run

Logical indicating if the model should be run or not. Default isTRUE, may be set to FALSE if the model should only be compiled but not run through Stan.

verbose

Logical indicating if Stan should print intermediate output while running the model. Default is TRUE and warnings and output will be printed

comp.model

Optional argument supplying a previously compiled Stan model to be run if compilation is set to FALSE

testing

Logical if the sampling should be done using the "Fixed_param" algorithm and single iterations in Stan, default is FALSE. Can be set to true for the purposes of testing the logposterior

Value

A StanNetRun object, containing the following elements: fit - The stanfit object resulting from MCMC sampling model - The StanNetModel object comp.model - The compiled Stan model scale, family, link, effects - The scale, family, link, and type of effects from the StanNetModel trt.key - A key indicating the reference treatment and indexing the other treatments


augustinewigle/StanNet documentation built on July 21, 2020, 12:13 a.m.