estimate_G: Estimate the Atoms and Weights of the Discrete Mixing...

View source: R/04_VI_estimate_G.R

estimate_GR Documentation

Estimate the Atoms and Weights of the Discrete Mixing Distributions

Description

The function computes the posterior means of the atoms and weights characterizing the discrete mixing distributions. The function takes as input an object from fit_CAM, fit_fiSAN, or fit_fSAN, used with the est_method = "VI" argument, and returns an object of class SANvi_G.

Usage

estimate_G(object)

## S3 method for class 'SANvi_G'
plot(x, DC_num = NULL, lim = 2, ...)

## S3 method for class 'SANvi_G'
summary(object, thr = 0.01, ...)

## S3 method for class 'SANvi_G'
print(x, thr = 0.01, ...)

Arguments

object

an object of class SANvi_G (usually, the result of a call to estimate_G).

x

an object of class SANvi_G (usually, the result of a call to estimate_G).

DC_num

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

lim

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

...

ignored.

thr

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

Value

The function estimate_G returns an object of class SANvi_G, which is a matrix comprising the posterior means, variances, and weights of each estimated DC (one mixture component for each row).

Examples

# Generate example data
set.seed(123)
y <- c(rnorm(100),rnorm(100,5))
g <- rep(1:2,rep(100,2))
plot(y,col=g)
# Fitting fiSAN via variational inference
est <- fit_fiSAN(y,g,vi_param= list(n_runs = 10))
est
summary(est)
# Estimate posterior atoms and weights
G <- estimate_G(est)
summary(G)

sanba documentation built on Aug. 8, 2025, 6:15 p.m.