The baygel R
package provides data-augmented block Gibbs samplers,
for Bayesian shrinkage methods, to return the posterior distribution of
precision matrices for Gaussian distributed data with positive
definite covariance matrix. The package is implemented within the
following literature, including Smith et
al. (2022) and Smith et
al. (2023). The Bayesian
(adaptive) graphical lasso block Gibbs samplers of H. Wang
(2012) are also included for
convenience.
You can install the latest version from CRAN using:
install.packages("baygel")
library(baygel)
library(baygel)
# Generate true covariance matrix:
p <- 10
n <- 500
OmegaTrue <- pracma::Toeplitz(c(0.7^rep(1:p-1)))
SigTrue <- pracma::inv(OmegaTrue)
# Generate expected value vector:
mu <- rep(0,p)
# Generate multivariate normal distribution:
set.seed(123)
X <- MASS::mvrnorm(n, mu = mu, Sigma = SigTrue)
# Generate posterior distribution:
posterior <- blockBAGR(X,iterations = 1000, burnin = 500)
# Estimated precision matrix
OmegaEst <- apply(simplify2array(posterior$Omega), 1:2, mean)