hbcc | R Documentation |
This function is designed to evaluate the convergence and quality of a Bayesian hierarchical model. It performs several diagnostic tests and generates various plots to assess Markov Chain Monte Carlo performance.
hbcc(
model,
diag_tests = c("rhat", "geweke", "heidel", "raftery"),
plot_types = c("trace", "dens", "acf", "nuts_energy", "rhat", "neff")
)
model |
A |
diag_tests |
Character vector of diagnostic tests (default:"rhat", "geweke", "raftery", "heidel") |
plot_types |
Character vector of plot types (default: trace","dens","acf", "nuts_energy", "rhat", "neff") |
Hierarchical Bayesian Convergence Checks
An object of class hbcc_results
, which is a list containing:
rhat_ess |
Matrix of |
geweke |
Geweke diagnostic results (if selected). |
raftery |
Raftery-Lewis diagnostic results (if selected). |
heidel |
Heidelberger-Welch diagnostic results (if selected). |
plots |
A list of generated MCMC diagnostic plots, which may include: |
"trace"
- Trace plot of the MCMC chains.
"dens"
- Density plot of the posterior distributions.
"acf"
- Autocorrelation function plot.
"nuts_energy"
- NUTS energy diagnostic plot.
"rhat"
- Rhat plot (if available).
"neff"
- Effective sample size plot.
Achmad Syahrul Choir and Saniyyah Sri Nurhayati
Bürkner, P. C. (2017). brms: An R package for Bayesian multilevel models using Stan. Journal of Statistical Software, 80(1), 1-28.
library(hbsaems)
data("data_fhnorm")
# Prepare the dataset
data <- data_fhnorm
# Fit the Basic Model
model <- hbm(
formula = bf(y ~ x1 + x2 + x3), # Formula model
hb_sampling = "gaussian", # Gaussian family for continuous outcomes
hb_link = "identity", # Identity link function (no transformation)
data = data, # Dataset
chains = 4, # Number of MCMC chains
iter = 4000, # Total MCMC iterations
warmup = 2000, # Number of warmup iterations
cores = 2 # Parallel processing
)
summary(model)
# Convergence Checks
hbcc(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.