Learn R Programming

SANvi (version 0.1.1)

estimate_atoms_weights_vi: Estimate the Posterior Atoms and Weights of the Discrete Mixing Distributions

Description

This function estimates the posterior atoms and weights characterizing the discrete mixing distributions using the variational estimates obtained from one of the model implemented in SANvi.

Usage

estimate_atoms_weights_vi(output)

# S3 method for vi_atoms_weights plot(x, DC_num = NULL, lim = 2, ...)

# S3 method for vi_atoms_weights print(x, thr = 0.01, ...)

Value

an object of class vi_atoms_weights, which is matrix comprising posterior means, variances, and a columns for each estimated DC containing the posterior weights.

Arguments

output

an object of class SANvb, which is the output of one of the variational functions variational_CAM, variational_fiSAN, variational_fSAN.

x

an object of class variational_estimates, which can be obtained from the function estimate_atoms_weights_vi.

DC_num

an integer or a vector of integers indicating which distributional clusters to plot.

lim

optional value for plot method to adjust the limits of the x-axis. The atoms are plotted on a range given by min(posterior means)-2, max(posterior means)+2. Default is set to 2.

...

ignored.

thr

argument for the print() method. It should be a small positive number, representing a threshold. If the posterior weight of a shared atom is below the threshold, the atom is not reported.

See Also

variational_CAM, variational_fiSAN, variational_fSAN, extract_best.

Examples

Run this code
# Generate example data
set.seed(1232)
y <- c(rnorm(100),rnorm(100,5))
g <- rep(1:2,rep(100,2))

# Fitting fiSAN via variational inference
est <- variational_fiSAN(y,g,verbose = FALSE)

# Estimate posterior atoms and weights
estimate_atoms_weights_vi(est)

Run the code above in your browser using DataLab