beta_sar: Small Area Estimation using Hierarchical Bayesian Method...

View source: R/beta_sar.R

beta_sarR Documentation

Small Area Estimation using Hierarchical Bayesian Method under Spatial Beta SAR Model

Description

This function gives small area estimator under Spatial SAR Model. It is implemented to a variable of interest (y) that is assumed to follow a Beta Distribution. The range of data is 0 < y < 1.

Usage

beta_sar(
  formula,
  proxmat,
  data,
  iter.update = 3,
  iter.mcmc = 2000,
  thin = 1,
  burn.in = 1000,
  chains = 2,
  n.adapt = 1000,
  coef = NULL,
  var.coef = NULL,
  tau.u = 1,
  seed = 123,
  quiet = FALSE,
  plot = TRUE,
  keep.fit = FALSE
)

Arguments

formula

Formula that describes the fitted model.

proxmat

N \times N row-standardized proximity matrix with values in the interval [0,1] representing the spatial proximity between areas. The rows sum to 1.

data

The data frame.

iter.update

Number of updates performed during Gibbs sampling. Default is 3.

iter.mcmc

Total number of MCMC iterations per chain. Default is 2000.

thin

Thinning rate for MCMC sampling. Must be a positive integer. Default is 1.

burn.in

Number of burn-in iterations discarded from each MCMC chain. Default is 1000.

chains

Number of parallel MCMC chains. Default is 2.

n.adapt

Number of iterations used for the adaptation phase in JAGS. Default is 1000.

coef

Optional vector containing the mean of the prior distribution of the regression model coefficients.

var.coef

Optional vector containing the variances of the prior distribution of the regression model coefficients.

tau.u

Initial value or shape for the random effect precision. Default is 1.

seed

An integer seed for the random number generator to ensure reproducibility. Default is 123.

quiet

Logical; if TRUE, suppresses the JAGS terminal output. Default is FALSE.

plot

Logical; if TRUE, generates MCMC diagnostic trace, autocorrelation, and density plots. Default is TRUE.

keep.fit

Logical; if TRUE, keeps the raw MCMC coda samples object in the output list. Default is FALSE.

Value

This function returns a list with the following objects:

est

A dataframe containing the posterior mean estimates, posterior standard deviations, and 95% credible intervals of the small area means estimated using the Hierarchical Bayesian method.

randeff

A dataframe containing the posterior mean estimates, posterior standard deviations, and 95% credible intervals of the area-specific random effects (v).

refvar

A dataframe containing the posterior mean estimates, posterior standard deviations, and 95% credible intervals of the area-specific random effect variances (a.var).

coefficient

A dataframe containing the posterior mean estimates, posterior standard deviations, 95% credible intervals, Rhat convergence diagnostics, and Effective Sample Sizes (ESS) for the regression coefficients (\beta), the spatial autoregressive parameter (\rho), and the global precision parameter (\phi).

Examples

# Load dataset and proximity matrix
data(databeta)
data(weight_mat)


# Fit the Spatial Beta-SAR model
result <- beta_sar(
  formula = y ~ x1 + x2,
  proxmat = weight_mat,
  data = databeta
)

# View the estimation results
# 1. Small Area Estimates
result$est
# 2. Estimated area-specific random effects
result$randeff
# 3. Estimated variance of the random effects
result$refvar
# 4. Estimated regression coefficients, spatial, and precision parameters
result$coefficient



saeHB.Spatial.Beta documentation built on July 1, 2026, 5:07 p.m.