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 "fiSAN","CAM", or "fSAN".

maxL, maxK

integers, the upper bounds for the observational and distributional clusters to fit, respectively.

m0, tau0, lambda0, gamma0

hyperparameters on (\mu, \sigma^2) \sim NIG(m_0, \tau_0, \lambda_0,\gamma_0).

conc_hyperpar, conc_par, alpha_bar, beta_bar

these values crucially depend on the chosen model. See variational_CAM, variational_fiSAN, variational_fSAN for proper explanations.

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 TRUE, the observational means of the cluster atoms are initialized with a k-means algorithm.

x

an object of class multistart, obtained from the variational_multistart function.

type

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.

log_scale_iter

logical. If TRUE, when plotting the elbo trajectories, the x-axes is displayed in log-scale, enhancing the visualization of the results.

...

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)


[Package SANvi version 0.1.1 Index]