Learn R Programming

hbsaems (version 0.1.1)

hbsae: 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)

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.

Arguments

model

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

newdata

A dataset for making predictions.

Author

Achmad Syahrul Choir and Saniyyah Sri Nurhayati

Details

Hierarchical Bayesian Small Area Estimation

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

Run this code
# \donttest{

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)
# }

Run the code above in your browser using DataLab