Learn R Programming

SANvi (version 0.1.1)

estimate_clustering_vi: Estimate Posterior Clustering Assignments

Description

This function estimates posterior clustering assignments based on posterior variational estimates obtained from one of the model implemented in SANvi.

Usage

estimate_clustering_vi(output, ordered = TRUE)

# S3 method for vi_clustering plot( x, DC_num = NULL, type = c("ecdf", "boxplot", "scatter"), palette_brewed = FALSE, ... )

# S3 method for vi_clustering print(x, ...)

Value

a list of class clustering containing

  • obs_level: a data frame containing the data values, their group indexes, the observational and distributional clustering assignments for each observation.

  • dis_level: a vector with the distributional clustering assignment for each unit.

Arguments

output

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

ordered

logical, if TRUE (default), the function sorts the distributional cluster labels reflecting the increasing values of medians of the data assigned to each DC.

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.

type

what type of plot should be drawn (only for the left-side plot). Possible types are "boxplot", "ecdf", and "scatter".

palette_brewed

(logical) the color palette to be used. Default is R base colors (palette_brewed = FALSE).

...

ignored.

See Also

variational_CAM, variational_fiSAN, variational_fSAN, extract_best.

Examples

Run this code
# \donttest{
# Generate example data
set.seed(123)
y <- c(rnorm(100),rnorm(100,-5),rnorm(100,5),rnorm(100),
       rnorm(100),rnorm(100,-5),rnorm(100,5),rnorm(100))
g <- rep(1:4,rep(200,4))

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

# Estimate clustering assignments
estimate_clustering_vi(est)
# }

Run the code above in your browser using DataLab