Learn R Programming

rstan (version 2.9.0-3)

vb-methods: Run Stan's Variational Algorithm for Approximate Posterior Sampling

Description

Approximately draw from a posterior distribution using variational inference. We recommend calling stan or sampling for final inferences and only using vb to get a rough idea of the parameter distributions.

Usage

## S3 method for class 'stanmodel':
vb(object, data = list(), pars = NA, include = TRUE,
    seed = sample.int(.Machine$integer.max, 1),
    init = 'random',
    check_data = TRUE, sample_file = tempfile(fileext = '.csv'),
    algorithm = c("meanfield", "fullrank"), ...)

Arguments

object
An object of class stanmodel.
data
A named list or environment providing the data for the model or a character vector for all the names of objects used as data. See the notes in stan.
pars
If not NA, then a character vector naming parameters, which are included in the output if include = TRUE and excluded if include = FALSE. By default, all parameters are included.
include
Logical scalar indicating whether to include (the default) or exclude the parameters named in pars
seed
The seed for random number generation. The default is generated from 1 to the maximum integer supported by Ron the machine. When a seed is specified by a number, as.integer will be applied to it. If as.integer produc
init
One of digit 0, string "0" or "random", a function that returns a list, or a named list of initial parameter values. "0": initialize all to be zero on the unconstrained support; "
check_data
Logical: if TRUE, the data would be preprocessed; otherwise not. If the data is not checked and preprocessed, it is safe to leave it to be the default TRUE. See the notes in stan

Value

See Also

stanmodel The manuals of CmdStan and Stan.

Examples

Run this code
m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')
f <- vb(m)

Run the code above in your browser using DataLab