Skip to contents

Model fitting (entry points)

Three layers of API for fitting a hierarchical Bayesian SAE model, from the most user-friendly distribution-specific wrappers to the universal brms interface, plus the post-fit refit helper.

hbm()
hbm: Hierarchical Bayesian Small Area Models
hbm_flex()
Fit a Flexible HBSAE Model with Any Registered Family
hbm_lnln()
Small Area Estimation under a Lognormal-Lognormal Model
hbm_betalogitnorm()
Small Area Estimation Under a Beta Likelihood (Logit-Normal Link)
hbm_binlogitnorm()
Small Area Estimation under a Binomial Logit-Normal Model
update_hbm()
Update a Fitted HBM

Pre-fit data & spatial-weight checking

Validate data structure, missing-data patterns, and adjacency matrices before fitting.

check_data()
Inspect Data Before Fitting an HBSAE Model
check_spatial_weight()
Validate a Spatial Weight Matrix Against CAR/SAR Theory
build_spatial_weight()
build_spatial_weight: Construct M for CAR / SAR models

Configuration bundles

Helpers for assembling sampler / prior / nonlinear-term arguments into reusable named lists that can be passed to hbm() and its wrappers.

hbm_control()
Sampler Configuration for HBSAE Models
hbm_priors()
Prior Configuration for HBSAE Models
hbm_nonlinear()
Nonlinear-Term Configuration for HBSAE Models

Bayesian workflow — diagnostics & comparison

Post-fit assessment of MCMC convergence, predictive performance, model selection, model averaging, and prior sensitivity. Together these cover stages 1, 3–7 of the canonical Bayesian workflow (Gelman et al. 2020).

prior_check()
Prior Predictive Check for Fitted HBMs
convergence_check()
MCMC Convergence Diagnostics for Fitted HBMs
is_converged()
Test Whether a Fitted HBM Has Converged
diagnostic_summary()
Extract a Diagnostic Summary
model-compare
Compare Fitted HBMs
model_compare()
Compare One or Two Fitted HBMs
model_compare_all()
Compare Multiple Fitted HBMs
model_average()
Bayesian Model Averaging on Small-Area Estimates
prior_sensitivity()
Power-Scale Prior Sensitivity Diagnostics for Fitted HBMs
is.hbsaems_check()
Test Whether an Object Is an hbsaems Check Result
summary(<hbsaems_check>)
Generic Summary Method for hbsaems Check Results

Prediction & benchmarking

Out-of-sample prediction for unsampled areas (in-sample EBLUP and posterior predictive draws) and design-consistent benchmarking against direct estimates (Pfeffermann-style raking and ratio).

sae_predict()
Generate Small Area Estimates
sae_benchmark()
Benchmark Small-Area Estimates to Known Totals
sae_aggregate()
Aggregate Predictions from Multiple hbsae_results
sae_scale()
Standardise SAE Predictions
sae_transform()
Apply a Transformation to SAE Predictions
sae_filter()
Filter SAE Predictions by a Logical Condition

Posterior & prior extraction

Light-touch helpers for extracting draws, summaries, and credible intervals from hbmfit / brmsfit objects, including the prior-only fit produced by sample_prior = "only".

posterior_draws()
Extract Posterior Draws as a Matrix
posterior_interval(<hbmfit>)
Compute Credible Intervals for an hbmfit Object
posterior_summary_hbm()
Comprehensive Posterior Summary
prior_draws(<hbmfit>)
Extract Prior Draws

Custom brms families

Built-in custom distributions (loglogistic and shifted loglogistic) plus the framework for registering new families and Stan log-pdf functions through the model registry.

brms_custom_loglogistic()
Loglogistic as a Custom Distribution Family for brms
brms_custom_shifted_loglogistic()
Shifted Loglogistic as a Custom Distribution Family for brms
dloglogistic() ploglogistic() qloglogistic() rloglogistic()
Loglogistic Distribution Functions
dshifted_loglogistic() pshifted_loglogistic() qshifted_loglogistic() rshifted_loglogistic()
Shifted (3-Parameter) Loglogistic Distribution
build_brms_custom_family()
Build a brms Custom Family + Stanvars Pair from a Single Spec
read_stan_function()
Read the Stan Function Code for a Custom Distribution
register_hbsae_brms_custom()
Register a brms Custom Family with the hbsaems Model Registry
register_hbsae_model()
Register a Custom HBSAE Model
list_hbsae_models()
List Registered HBSAE Models
get_hbsae_model()
Inspect a Registered HBSAE Model Specification

Object methods & internal state

S3 constructors, validators, and methods for the hbmfit class along with helpers to inspect a fitted model’s metadata, raw data, and any warnings raised during fitting.

hbmfit()
User-Facing Helper to Build an hbmfit Object
new_hbmfit()
Create a New hbmfit Object
validate_hbmfit()
Validate an hbmfit Object
hbmfit-class
The hbmfit S3 Class
hbm_data()
Return the Data Used to Fit an hbmfit
hbm-info
Model Inspection Helpers
hbm_info()
Get Comprehensive Model Information
hbm_warnings()
Get Model Warnings
is.hbmfit() is.hbcc_results() is.hbmc_results() is.hbpc_results() is.hbsae_results()
Test Whether an Object Belongs to an hbsaems Result Class
hbmfit-methods
Standard S3 Methods for hbmfit
posterior-methods
Posterior and Prior Extraction Methods for hbmfit
plot(<hbmfit>)
Plot a Fitted hbmfit Object

Shiny dashboard

Launch the interactive bilingual (English / Indonesian) SAE GUI and inspect its translation infrastructure.

run_sae_app()
run_sae_app: Interactive Small Area Estimation Application
check_shiny_deps()
Check Shiny App Dependencies
tr()
Translate a UI String for the Shiny SAE App
tr_langs()
List Available Languages
tr_keys()
List All Translation Keys (for a Reference Language)

Datasets

Example datasets shipped for vignettes and tests, including spatial adjacency matrices used by the CAR / SAR / BYM2 examples.

data_fhnorm
Simulated Fay-Herriot Normal Data
data_lnln
Simulated Lognormal-Lognormal Data
data_betalogitnorm
Simulated Beta Logit-Normal Data
data_binlogitnorm
Simulated Binomial Logit-Normal Data
adjacency_matrix_car
Province-level Adjacency Matrix
adjacency_matrix_car_regency
Regency-level Adjacency Matrix (Coarse Spatial Cluster)
spatial_weight_sar
Spatial Weight Matrix for Simultaneous Autoregressive Models

Deprecated

Retained for backward compatibility; scheduled for removal in v2.0.0. Use the modern replacements listed in each function’s documentation.

hbcc() hbmc() hbpc() hbsae()
Deprecated Functions