`stanmodel-method-vb.Rd`

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.

<!-- %% vb(object, \dots) --> # S4 method for 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 |

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: `iter` (positive`integer` ), the maximum number of iterations, defaulting to 10000.`grad_samples` (positive`integer` ), the number of samples for Monte Carlo estimate of gradients, defaulting to 1.`elbo_samples` (positive`integer` ), the number of samples for Monte Carlo estimate of ELBO (objective function), defaulting to 100. (ELBO stands for "the evidence lower bound".)`eta` (`double` ), positive stepsize weighting parameter for variational inference but is ignored if adaptation is engaged, which is the case by default.`adapt_engaged` (`logical` ), a flag indicating whether to automatically adapt the stepsize, defaulting to`TRUE` .`tol_rel_obj` (positive`double` ), the convergence tolerance on the relative norm of the objective, defaulting to 0.01.`eval_elbo` (positive`integer` ), evaluate ELBO every Nth iteration, defaulting to 100.`output_samples` (positive`integer` ), number of posterior samples to draw and save, defaults to 1000.`adapt_iter` (positive`integer` ), the maximum number of iterations to adapt the stepsize, defaulting to 50. Ignored if`adapt_engaged = FALSE` .
Refer to the manuals for both CmdStan and Stan for more details. |

- vb
`signature(object = "stanmodel")`

Call Stan's variational Bayes methods
for the model defined by S4 class

`stanmodel`

given the data, initial values, etc.
An object of `stanfit-class`

.

The manuals of CmdStan and Stan.

The Stan Development Team
*Stan Modeling Language User's Guide and Reference Manual*.
http://mc-stan.org.

The Stan Development Team
*CmdStan Interface User's Guide*.
http://mc-stan.org.

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