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.
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 multistart
plot(x, type = c("elbo", "time"), log_scale_iter = TRUE, ...)
# S3 method for multistart
print(x, ...)
A list with all the runs performed. Each element of the list is a fitted variational model of class SANvb.
vector of observations.
vector of the same length of y indicating the group membership (numeric).
the number of multiple runs to launch.
the number of cores to dedicate to the multiple runs.
a string specifying the model to use. It can be "fiSAN","CAM", or "fSAN".
integers, the upper bounds for the observational and distributional clusters to fit, respectively.
hyperparameters on \((\mu, \sigma^2) \sim NIG(m_0, \tau_0, \lambda_0,\gamma_0)\).
these values crucially depend on the chosen model. See variational_CAM, variational_fiSAN, variational_fSAN for proper explanations.
the tolerance that drives the convergence criterion adopted as stopping rule.
common part of the random seeds used to control the initialization in order to provide reproducibility even in paralleled settings.
the maximum number of CAVI iteration to perform.
logical, if TRUE, the observational means of the cluster atoms are initialized with a k-means algorithm.
an object of class multistart, obtained from the variational_multistart function.
a string specifying the type of plot. It can be either "elbo" or "time". The former displays
the elbo trajectories, highlighting the best run. The latter provides a summary of the computational times.
logical. If TRUE, when plotting the elbo trajectories, the x-axes is displayed in log-scale, enhancing the visualization of the results.
ignored
For the details of the single models, see their specific documentations: variational_CAM, variational_fiSAN, and variational_fSAN.
variational_CAM, variational_fiSAN, variational_fSAN, extract_best.
# \donttest{
# 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)
# }
Run the code above in your browser using DataLab