Learn R Programming

baygel (version 0.3.0)

blockBGEN: Naive Bayesian graphical elastic net block Gibbs sampler for Gaussian graphical models.

Description

Implements the Bayesian graphical elastic net block Gibbs sampler to simulate the posterior distribution of the precision matrix for Gaussian graphical models.

Usage

blockBGEN(X, burnin, iterations, lambda = 1, sig = 1, verbose = TRUE)

Value

A list containing precision `Omega` and covariance `Sigma` matrices from the Markov chains.

Arguments

X

A numeric matrix, assumed to be generated from a multivariate Gaussian distribution.

burnin

An integer specifying the number of burn-in iterations.

iterations

An integer specifying the length of the Markov chain after the burn-in iterations.

lambda

A numeric value representing the rate parameter for the double exponential and exponential prior associated with the Bayesian graphical lasso penalty term.

sig

A numeric value representing the standard deviation parameter for the double Gaussian and truncated Gaussian prior associated with the Bayesian graphical ridge penalty term.

verbose

A logical determining whether the progress of the MCMC sampler should be displayed.

Examples

Run this code
# Generate true precision 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     <- blockBGEN(X, iterations = 1000, burnin = 500, lambda = 1, sig = 1)
# Estimated precision matrix using the mean of the posterior:
OmegaEst      <- apply(simplify2array(posterior$Omega), 1:2, mean)

Run the code above in your browser using DataLab