vb | R Documentation |
Approximately draw from a posterior distribution using variational inference.
This is still considered an experimental feature.
We recommend calling stan
or sampling
for
final inferences and only using vb
to get a rough idea of the parameter
distributions.
## S4 method for signature '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"),
importance_resampling = FALSE, keep_every = 1,
...)
object |
An object of class |
data |
A named |
pars |
If not |
include |
Logical scalar defaulting to |
seed |
The seed for random number generation. The default is generated
from 1 to the maximum integer supported by R on the machine. Even if
multiple chains are used, only one seed is needed, with other chains having
seeds derived from that of the first chain to avoid dependent samples.
When a seed is specified by a number, |
init |
Initial values specification. See the detailed documentation for
the init argument in |
check_data |
Logical, defaulting to |
sample_file |
A character string of file name for specifying where to write samples for all parameters and other saved quantities. This defaults to a temporary file. |
algorithm |
Either |
importance_resampling |
Logical scalar (defaulting to |
keep_every |
Integer scalar (defaulting to 1) indicating the interval
by which to thin the draws when |
... |
Other optional parameters:
Refer to the manuals for both CmdStan and Stan for more details. |
An object of stanfit-class
.
signature(object = "stanmodel")
Call Stan's variational Bayes methods
for the model defined by S4 class stanmodel
given the data, initial values, etc.
The Stan Development Team Stan Modeling Language User's Guide and Reference Manual. https://mc-stan.org.
The Stan Development Team CmdStan Interface User's Guide. https://mc-stan.org.
stanmodel
The manuals of CmdStan and Stan.
## Not run:
m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')
f <- vb(m)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.