variational_multistart {SANvi} | R Documentation |
Perform variational inference using multiple starting points.
Description
variational_multistart
is the main function of the package.
It is used to estimate via variational inference the three models we present (CAM, fiSAN, fSAN) while adopting multiple random starting points to better explore the variational parameter space.
The run that provides the highest Expected Lower BOund (ELBO) is usually the one considered for inference. Note that the arguments passed to this functions are a union of the arguments
of the functions variational_CAM
, variational_fiSAN
, and variational_fSAN
.
Usage
variational_multistart(y, group, runs, cores = 1,
model = c("fiSAN","CAM","fSAN"),
maxL = 30, maxK = 20,
m0 = 0, tau0 = .01, lambda0 = 3, gamma0 = 2,
conc_par = NULL, conc_hyperpar = c(1,1,1,1),
alpha_bar = 0.05, beta_bar = 0.05,
epsilon = 1e-6, root = 1234, maxSIM = 1e5,
warmstart = TRUE)
## S3 method for class 'multistart'
plot(x, type = c("elbo", "time"), log_scale_iter = TRUE, ...)
## S3 method for class 'multistart'
print(x, ...)
Arguments
y |
vector of observations. |
group |
vector of the same length of y indicating the group membership (numeric). |
runs |
the number of multiple runs to launch. |
cores |
the number of cores to dedicate to the multiple runs. |
model |
a string specifying the model to use. It can be |
maxL , maxK |
integers, the upper bounds for the observational and distributional clusters to fit, respectively. |
m0 , tau0 , lambda0 , gamma0 |
hyperparameters on |
conc_hyperpar , conc_par , alpha_bar , beta_bar |
these values crucially depend on the chosen model. See |
epsilon |
the tolerance that drives the convergence criterion adopted as stopping rule. |
root |
common part of the random seeds used to control the initialization in order to provide reproducibility even in paralleled settings. |
maxSIM |
the maximum number of CAVI iteration to perform. |
warmstart |
logical, if |
x |
an object of class |
type |
a string specifying the type of plot. It can be either |
log_scale_iter |
logical. If |
... |
ignored |
Details
For the details of the single models, see their specific documentations: variational_CAM
, variational_fiSAN
, and variational_fSAN
.
Value
A list with all the runs performed. Each element of the list is a fitted variational model of class SANvb
.
See Also
variational_CAM
, variational_fiSAN
, variational_fSAN
, extract_best
.
Examples
# Generate example data
set.seed(123)
y <- c(rnorm(100),rnorm(100,5))
g <- rep(1:2,rep(100,2))
# Estimate multiple models via variational inference
est <- variational_multistart(y, g, runs=5)