MyNixOS website logo
Description

Bayesian Clustering Factor Models.

Implements the Bayesian Clustering Factor Models (BCFM) for simultaneous clustering and latent factor analysis of multivariate longitudinal data. The model accounts for within-cluster dependence through shared latent factors while allowing heterogeneity across clusters, enabling flexible covariance modeling in high-dimensional settings. Inference is performed using Markov chain Monte Carlo (MCMC) methods with computationally intensive steps implemented via 'Rcpp'. Model selection and visualization tools are provided. The methodology is described in Shin, Ferreira, and Tegge (2018) <doi:10.1002/sim.70350>.

BCFM

Bayesian Clustering Factor Models (BCFM) for clustering and latent factor analysis of multivariate cross-sectional data.

Installation

You can install the development version of BCFM from GitHub with:

# install.packages("devtools")
devtools::install_github("ategge/BCFM", build_vignettes = TRUE)

Example

This is a basic example which shows you how to use BCFM:

library(BCFM)

# Load example data
data("sim.data", package = "BCFM")

# Specify variables to use for clustering
cluster.vars <- paste0("V", 1:20)

# Create output directory for results
# Use tempdir() for examples, or specify your own directory for real analyses
output_dir <- file.path(tempdir(), "BCFM_results")

# Run model selection
BCFM.model.selection(
  data = sim.data,
  cluster.vars = cluster.vars,   # Required parameter
  grouplist = 2:4,               # Try 2, 3, and 4 groups
  factorlist = 2:4,              # Try 2, 3, and 4 factors
  n.iter = 10000,                # Number of MCMC iterations
  burnin = 5000,                 # Burnin for Information Criterion calculations
  every = 10,                    # Progress update frequency
  cluster.size = 0.01,           # Minimum proportion required for each cluster (default 0.05)
  output_dir = output_dir,       # Specify where to save results
  seed = 123                     # Optional seed for reproducibility
)

# Results are saved in output_dir
# Load and visualize IC results
load(file.path(output_dir, "IC.Rdata"))
ggplot_IC(IC.matrix, factor_list = 2:4, group_list = 2:4)

# Load and visualize model results for 4 groups and 3 factors
load(file.path(output_dir, "results-covarianceF-g4-f3.Rdata"))
ggplot_latent.profiles(SDresult$Result)

Vignette

For a complete workflow tutorial, see the vignette:

# After installation with build_vignettes = TRUE
vignette("introduction-to-BCFM", package = "BCFM")

# Or browse all vignettes
browseVignettes("BCFM")

Features

  • Bayesian clustering with latent factor models
  • Model selection across different numbers of groups and factors
  • Comprehensive visualization functions
  • Example datasets included
  • Detailed vignette with complete workflow

Citation

If you use BCFM in your research, please cite:

[Add your citation here when you have a publication]

License

GPL-3

Metadata

Version

1.0.0

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • 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-linux
  • 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-uefi
  • x86_64-windows