run_banocc: Runs BAnOCC to fit the model and generate appropriate...

Description Usage Arguments Value See Also Examples

View source: R/run_banocc.R

Description

Runs BAnOCC to fit the model and generate appropriate convergence metrics and inference.

Usage

1
2
3
4
run_banocc(compiled_banocc_model, C, n = rep(0, ncol(C)), L = 10 *
  diag(ncol(C)), a = 0.5, b = 0.01, cores = getOption("mc.cores", 1L),
  chains = 4, iter = 50, warmup = floor(iter/2), thin = 1,
  init = NULL, control = NULL, verbose = FALSE, num_level = 0)

Arguments

compiled_banocc_model

The compiled stan model (as with stan_model(model_code = banocc_model)).

C

The dataset as a data frame or matrix. This should be N by P with N samples as the rows and P features as the columns.

n

The prior mean for m; vectors of length less than P (the number of features/columns of C) will be recycled.

L

The prior variance-covariance for m (must be positive-definite with dimension PxP where P=number of features/columns in C), or a vector of length p of variances for m. If a vector of length less than P is given, it will be recycled.

a

The shape parameter of a gamma distribution (the prior on the shrinkage parameter lambda)

b

The rate parameter of a gamma distribution (the prior on the shrinkage parameter lambda)

cores

Number of cores to use when executing the chains in parallel, which defaults to 1 but we recommend setting the mc.cores option to be as many processors as the hardware and RAM allow (up to the number of chains).

chains

A positive integer specifying the number of Markov chains. The default is 4.

iter

A positive integer specifying the number of iterations for each chain (including warmup). The default is 2000.

warmup

A positive integer specifying the number of warmup (aka burnin) iterations per chain. If step-size adaptation is on (which it is by default), this also controls the number of iterations for which adaptation is run (and hence these warmup samples should not be used for inference). The number of warmup iterations should not be larger than iter and the default is iter/2.

thin

A positive integer specifying the period for saving samples. The default is 1, which is usually the recommended value.

init

The initial values as a list (see sampling in the rstan package). Default value is NULL, which means that initial values are sampled from the priors for parameters m and lambda while O is set to the identity matrix.

control

A named list of parameters to control the sampler's behavior. See the details in the documentation for the control argument in stan.

verbose

Print informative statements as the function executes?

num_level

The number of indentations to add to the output when verbose = TRUE.

Value

Returns a named list with the following elements:

Data

The data formatted as a named list that includes the input data (C) and the prior parameters (n, L, a, b)

Fit

The stanfit object returned by the call to sampling

See Also

vignette("banocc-vignette") for more examples.

Examples

1
2
3
4
5
6
7
  data(compositions_null)
  ## Not run: 
    compiled_banocc_model <- rstan::stan_model(model_code=banocc_model)
    b_stanfit <- run_banocc(C=compositions_null,
                            compiled_banocc_model=compiled_banocc_model)
  
## End(Not run)

banocc documentation built on Nov. 8, 2020, 8:08 p.m.