ZinbHB: Small Area Estimation using Hierarchical Bayesian under Zero...

View source: R/ZinbHB.R

ZinbHBR Documentation

Small Area Estimation using Hierarchical Bayesian under Zero Inflated Negative Binomial Distribution

Description

This function is implemented to variable of interest (y) that assumed to be a Zero Inflated Negative Binomial Distribution. The range of data is (y >= 0). This model can be used to handle overdispersion and excess zero in data.

Usage

ZinbHB(
  formula,
  iter.update = 3,
  iter.mcmc = 1100,
  coef.nonzero,
  coef.zero,
  var.coef.nonzero,
  var.coef.zero,
  thin = 1,
  burn.in = 600,
  tau.u = 1,
  tau.v = 1,
  data
)

Arguments

formula

Formula that describe the fitted model

iter.update

Number of updates with default 3

iter.mcmc

Number of total iterations per chain with default 1100

coef.nonzero

Optional vector containing initial values mu.b for the mean of the prior distribution of the log model coefficients (β) with default rep(0,nvar)

coef.zero

Optional vector containing initial values mu.g for the mean of the prior distribution of the logit model coefficients (γ) with default rep(0,nvar)

var.coef.nonzero

Optional vector containing initial values tau.b for the variance of the prior distribution on the log model coefficients (β) with default rep(1,nvar)

var.coef.zero

Optional vector containing initial values tau.g for the variance of the prior distribution of the logit model coefficients (γ) with default rep(1,nvar)

thin

Thinning rate, must be a positive integer with default 1

burn.in

Number of iterations to discard at the beginning with default 600

tau.u

Variance of random effect area for non-zero count of variable interest with default 1

tau.v

Variance of random effect area for zero count of variable interest with default 1

data

The data frame

Value

This function returns a list of the following objects:

Est

A dataframe that contains the values, standar deviation, and quantile of Small Area mean Estimates using Hierarchical bayesian method

refVar

Estimated random effect variances

coefficient

A data frame with the estimated model coefficient consist of beta (coefficient in the log model) and gamma (coefficient in the logit model)

plot.beta

Trace, Density, Autocorrelation Function Plot of MCMC samples beta

plot.gamma

Trace, Density, Autocorrelation Function Plot of MCMC samples gamma

Examples

## Compute Fitted Model
## y ~ x1 +x2, nvar = 3

## For data without any nonsampled area
## Load Dataset
data(dataZINB)
result <- ZinbHB(formula = y ~ x1 + x2, data = dataZINB)

## Result
result$Est                             # Small Area mean Estimates
result$refVar                          # refVar
result$coefficient                     # coefficient


# Load library 'coda' to execute the plot
# autocorr.plot(result$plot.beta[[3]])  # Generate ACF Plot beta
# plot(result$plot.beta[[3]])           # Generate Dencity and Trace plot beta
# autocorr.plot(result$plot.gamma[[3]]) # Generate ACF Plot gamma
# plot(result$plot.gamma[[3]])          # Generate Dencity and trace plot gamma


## For data with nonsampled area use dataZINBNS



saeHB.zinb documentation built on June 16, 2022, 9:05 a.m.