Binomial {saeHB} | R Documentation |
Small Area Estimation using Hierarchical Bayesian under Binomial Distribution
Description
This function is implemented to variable of interest (y)
that assumed to be a Binomial Distribution using Logit normal model. The data is an accumulation from the Bernoulli process which there are exactly two mutually exclusive outcomes of a case.
Usage
Binomial(
formula,
n.samp,
iter.update = 3,
iter.mcmc = 10000,
coef,
var.coef,
thin = 2,
burn.in = 2000,
tau.u = 1,
data
)
Arguments
formula |
Formula that describe the fitted model |
n.samp |
number of sample |
iter.update |
Number of updates with default |
iter.mcmc |
Number of total iterations per chain with default |
coef |
a vector contains prior initial value of Coefficient of Regression Model for fixed effect with default vector of |
var.coef |
a vector contains prior initial value of variance of Coefficient of Regression Model with default vector of |
thin |
Thinning rate, must be a positive integer with default |
burn.in |
Number of iterations to discard at the beginning with default |
tau.u |
Prior initial value of inverse of Variance of area random effect with default |
data |
The data frame |
Value
This function returns a list of the following objects:
Est |
A vector with the values of Small Area mean Estimates using Hierarchical bayesian method, if there is non sampled area, then the result of estimation of mu in nonsampled areas are the probabilites |
refVar |
Estimated random effect variances |
coefficient |
A dataframe with the estimated model coefficient |
plot |
Trace, Dencity, Autocorrelation Function Plot of MCMC samples |
Author(s)
Azka Ubaidillah [aut], Ika Yuni Wulansari [aut], Zaza Yuda Perwira [aut, cre], Jayanti Wulansari [aut, cre], Fauzan Rais Arfizain [aut,cre]
Examples
#Data Generation
set.seed(123)
m=30
x1=runif(m,0,1)
x2=runif(m,0,1)
b0=b1=b2=0.5
u=rnorm(m,0,1)
n.samp1=round(runif(m,10,30))
mu= exp(b0 + b1*x1+b2*x2+u)/(1+exp(b0 + b1*x1+b2*x2+u))
y=rbinom(m,n.samp1,mu)
vardir=n.samp1*mu*(1-mu)
dataBinomial=as.data.frame(cbind(y,x1,x2,n.samp=n.samp1,vardir))
dataBinomialNs = dataBinomial
dataBinomialNs$y[c(3,14,22,29,30)] <- NA
dataBinomialNs$vardir[c(3,14,22,29,30)] <- NA
dataBinomialNs$n.samp[c(3,14,22,29,30)] <- NA
##Compute Fitted Model
##y~x1+x2
## For data without any nonsampled area
formula = y~x1+x2
n.s = "n.samp"
vc = c(1,1,1)
c = c(0,0,0)
dat = dataBinomial
## Using parameter coef and var.coef
saeHBBinomial<-Binomial(formula,n.samp=n.s,iter.update=10,coef=c,var.coef=vc,data =dat)
saeHBBinomial$Est #Small Area mean Estimates
saeHBBinomial$refVar #Random effect variance
saeHBBinomial$coefficient #coefficient
#Load Library 'coda' to execute the plot
#autocorr.plot(saeHBBinomial$plot[[3]]) is used to generate ACF Plot
#plot(saeHBBinomial$plot[[3]]) is used to generate Density and trace plot
## Do not using parameter coef and var.coef
saeHBBinomial <- Binomial(formula,n.samp ="n.samp",data=dataBinomial)
## For data with nonsampled area use dataBinomialNs