Implements a Gibbs sampler for Bayesian inference on Mixed Graphical Models.
sampler_bmgm(
n = 1,
Beta,
theta,
type,
categories,
lambda,
M = 1000,
X_new,
variables,
std
)Number of samples to generate.
Precision matrix of the graphical model.
A list of parameters for each node.
Character vector indicating variable types.
Vector indicating the number of categories (for categorical variables).
Transformation parameter.
Number of Gibbs sampler iterations. Default is 1000.
Vector of known values for imputation. Default is `c(0,0,0)`.
Indicator vector specifying which variables to update.
Standard deviation used in the transformation.
A matrix containing the sampled data.
# Simulate example data
set.seed(123)
Beta <- diag(4) # Identity precision matrix
theta <- list(c(0,1), c(0,1), c(0.5,1), c(0.5,1))
type <- c("c", "c", "d", "d")
categories <- c(1,1,1,1)
lambda <- 1
# Run the Gibbs sampler
samples <- sampler_bmgm(n = 10, Beta = Beta, theta = theta, type = type,
categories = categories, lambda = lambda, M = 500)
# View first few samples
head(samples)
#> [,1] [,2] [,3] [,4]
#> [1,] 0.1174596 -0.3315458 1 0
#> [2,] -0.6580102 0.8552022 1 0
#> [3,] 1.4046843 0.3870831 0 1
#> [4,] -0.1852022 1.2209637 2 1
#> [5,] 0.5577310 1.4819340 1 1
#> [6,] -0.5973301 0.7894599 0 0