Package: SANvi 0.1.1
SANvi: Fitting Shared Atoms Nested Models via Variational Bayes
An efficient tool for fitting the nested common and shared atoms models using variational Bayes approximate inference for fast computation. Specifically, the package implements the common atoms model (Denti et al., 2023), its finite version (D'Angelo et al., 2023), and a hybrid finite-infinite model. All models use Gaussian mixtures with a normal-inverse-gamma prior distribution on the parameters. Additional functions are provided to help analyze the results of the fitting procedure. References: Denti, Camerlenghi, Guindani, Mira (2023) <doi:10.1080/01621459.2021.1933499>, D’Angelo, Canale, Yu, Guindani (2023) <doi:10.1111/biom.13626>.
Authors:
SANvi_0.1.1.tar.gz
SANvi_0.1.1.tar.gz(r-4.5-noble)SANvi_0.1.1.tar.gz(r-4.4-noble)
SANvi_0.1.1.tgz(r-4.4-emscripten)SANvi_0.1.1.tgz(r-4.3-emscripten)
SANvi.pdf |SANvi.html✨
SANvi/json (API)
NEWS
# Install 'SANvi' in R: |
install.packages('SANvi', repos = 'https://cloud.r-project.org') |
Bug tracker:https://github.com/fradenti/sanvi/issues1 issues
Last updated 11 months agofrom:65f991746a. Checks:3 OK. Indexed: no.
Target | Result | Latest binary |
---|---|---|
Doc / Vignettes | OK | Mar 12 2025 |
R-4.5-linux-x86_64 | OK | Mar 12 2025 |
R-4.4-linux-x86_64 | OK | Mar 12 2025 |
Exports:estimate_atoms_weights_viestimate_clustering_viextract_bestvariational_CAMvariational_fiSANvariational_fSANvariational_multistart
Dependencies:clicolorspacefarvergluelabelinglifecyclematrixStatsmunsellR6RColorBrewerRcppRcppArmadillorlangscalesviridisLite
Citation
To cite package ‘SANvi’ in publications use:
Denti F, D'Angelo L (2024). SANvi: Fitting Shared Atoms Nested Models via Variational Bayes. R package version 0.1.1, https://CRAN.R-project.org/package=SANvi.
Corresponding BibTeX entry:
@Manual{, title = {SANvi: Fitting Shared Atoms Nested Models via Variational Bayes}, author = {Francesco Denti and Laura D'Angelo}, year = {2024}, note = {R package version 0.1.1}, url = {https://CRAN.R-project.org/package=SANvi}, }
Readme and manuals
SANvi v0.1.1

The goal of SANvi is to estimate Bayesian nested mixture models via variational Bayes methods. Specifically, the package implements the common atoms model (Denti et al., 2023), its finite version (D’Angelo et al., 2023), and a hybrid finite-infinite model (D’Angelo and Denti, 2024+). All models use Gaussian mixtures with a normal-inverse-gamma prior distribution on the parameters. Additional functions are provided to help analyzing the results of the fitting procedure.
Installation
You can install the development version of SANvi from GitHub with:
# install.packages("devtools")
devtools::install_github("Fradenti/SANvi")
Example
This is a basic example which shows you how to solve a common problem:
library(SANvi)
#> Loading required package: scales
#> Loading required package: RColorBrewer
# 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 <- SANvi:::variational_fiSAN(y,g,verbose = FALSE)
plot(est)

# Estimate clustering
cl <- estimate_clustering_vi(est)
cl
#> Number of estimated OCs: 2
#> Number of estimated DCs: 2
plot(cl,palette_brewed = T)

plot(cl,palette_brewed = T,type = "scatter")

# Estimate posterior atoms and weights
aw <- estimate_atoms_weights_vi(est)
aw
#> Atoms with posterior weight > 0.01
#> ----------------------------------
#> Number of detected DCs: 2
#> ----------------------------------
#>
#> Distributional cluster # 1
#> post_mean post_var post_weight
#> 1 -0.071 0.93 0.999
#>
#> Distributional cluster # 2
#> post_mean post_var post_weight
#> 2 4.973 0.861 0.999
plot(aw)

References
D’Angelo, L., Canale, A., Yu, Z., Guindani, M. (2023). Bayesian nonparametric analysis for the detection of spikes in noisy calcium imaging data. Biometrics 79(2), 1370–1382.
D’Angelo, L., and Denti, F. (2024+). A finite-infinite shared atoms nested model for the Bayesian analysis of large grouped data sets. Working paper, 1–34.
Denti, F., Camerlenghi, F., Guindani, M., Mira, A., 2023. A Common Atoms Model for the Bayesian Nonparametric Analysis of Nested Data. Journal of the American Statistical Association. 118(541), 405–416.
Help Manual
Help page | Topics |
---|---|
Estimate the Posterior Atoms and Weights of the Discrete Mixing Distributions | estimate_atoms_weights_vi plot.vi_atoms_weights print.vi_atoms_weights |
Estimate Posterior Clustering Assignments | estimate_clustering_vi plot.vi_clustering print.vi_clustering |
Extract the best run from multiple trials | extract_best |
Plotting the variational inference output | plot.SANvb |
Print variational inference output | print.SANvb |
Mean Field Variational Bayes estimation of CAM | variational_CAM |
Mean Field Variational Bayes estimation of fiSAN | variational_fiSAN |
Mean Field Variational Bayes estimation of fSAN | variational_fSAN |
Perform variational inference using multiple starting points. | plot.multistart print.multistart variational_multistart |