MyNixOS website logo
Description

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>.

SANvi v0.1.1

R-CMD-check CRAN LastCommit Downloads(monthly) Downloads(total)

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.

Metadata

Version

0.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows