hbsae: hbsae : Hierarchical Bayesian Small Area Estimation

View source: R/hbsae.R

hbsaeR Documentation

hbsae : Hierarchical Bayesian Small Area Estimation

Description

This function performs Hierarchical Bayesian Small Area Estimation (HBSAE). It estimates predictions and computes the Relative Standard Error (RSE) based on the posterior predictive sample from the fitted Bayesian model.

Usage

hbsae(model, newdata = NULL)

Arguments

model

A brmsfit or hbmfit object, a fitted model from the brms package and hbsaems package.

newdata

A dataset for making predictions.

Details

Hierarchical Bayesian Small Area Estimation

Value

An object of class hbsae_results, which is a list containing:

rse_model

A numeric value indicating the overall relative standard error (RSE) of the model.

mse_model

A numeric value indicating the overall mean squared error (MSE) of the model estimates, representing the average estimation error across areas.

result_table

A data.frame containing predictions and associated statistics for each small area.

Author(s)

Achmad Syahrul Choir and Saniyyah Sri Nurhayati

References

Bürkner, P. C. (2017). brms: An R package for Bayesian multilevel models using Stan. Journal of Statistical Software, 80(1), 1-28.

Examples



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)

# Small Area Estimates
hbsae(model)


hbsaems documentation built on Aug. 8, 2025, 7:28 p.m.