View source: R/04_VI_estimate_G.R
estimate_G | R Documentation |
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
.
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, ...)
object |
an object of class |
x |
an object of class |
DC_num |
an integer or a vector of integers indicating which distributional clusters to plot. |
lim |
optional value for the |
... |
ignored. |
thr |
argument for the |
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).
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.