Learn R Programming

sanba (version 0.0.3)

plot_vi_allocation_prob: Plot Variational Cluster Allocation Probabilities

Description

Produces visualizations of the posterior cluster allocation probabilities from a SAN model fitted via variational inference. The function supports plotting either the observation-level (OC) or distribution-level (DC) allocation probabilities, depending on the argument distributional.

This function applies to objects returned by fit_CAM, fit_fiSAN, or fit_fSAN when used with est_method = "VI".

Usage

plot_vi_allocation_prob(object, distributional = FALSE, ...)

Value

The function plots the variational cluster allocation probabilities.

Arguments

object

An object of class SANvi, representing a model fitted via variational inference.

distributional

Logical (default FALSE). If FALSE, plots the allocation probabilities of individual observations to observational clusters (OC). If TRUE, plots the allocation probabilities of groups to distributional clusters (DC).

...

Additional graphical parameters passed to the underlying image() function (or equivalent), for customizing the plot (e.g., col, main, xlab, ylab).

Examples

Run this code
# Generate example data
set.seed(123)
y <- c(rnorm(60), rnorm(40, 5))
g <- rep(1:2, each = 50)

# Fit fiSAN via VI
est <- fit_fiSAN(y, g, est_method = "VI")

# Plot observational cluster probabilities
plot_vi_allocation_prob(est)

# Plot distributional cluster probabilities
plot_vi_allocation_prob(est, distributional = TRUE)

Run the code above in your browser using DataLab