Title: | SAE using HB Twofold Subarea Model under Beta Distribution |
Version: | 0.1.0 |
Maintainer: | Nasya Zahira Putri <nasyazp28@gmail.com> |
Description: | Estimates area and subarea level proportions using the Small Area Estimation (SAE) Twofold Subarea Model with a hierarchical Bayesian (HB) approach under Beta distribution. A number of simulated datasets generated for illustration purposes are also included. The 'rstan' package is employed to estimate parameters via the Hamiltonian Monte Carlo and No U-Turn Sampler algorithm. The model-based estimators include the HB mean, the variation of the mean, and quantiles. For references, see Rao and Molina (2015) <doi:10.1002/9781118735855>, Torabi and Rao (2014) <doi:10.1016/j.jmva.2014.02.001>, Leyla Mohadjer et al.(2007) http://www.asasrms.org/Proceedings/y2007/Files/JSM2007-000559.pdf, and Erciulescu et al.(2019) <doi:10.1111/rssa.12390>. |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Biarch: | true |
Depends: | R (≥ 3.5) |
Imports: | methods, Rcpp (≥ 0.12.0), RcppParallel (≥ 5.0.1), rstan (≥ 2.18.1), rstantools (≥ 2.4.0), bayesplot, stringr |
LinkingTo: | BH (≥ 1.66.0), Rcpp (≥ 0.12.0), RcppEigen (≥ 0.3.3.3.0), RcppParallel (≥ 5.0.1), rstan (≥ 2.18.1), StanHeaders (≥ 2.18.0) |
SystemRequirements: | GNU make |
URL: | https://github.com/Nasyazahira/saeHB.TF.beta |
BugReports: | https://github.com/Nasyazahira/saeHB.TF.beta/issues |
LazyData: | true |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
NeedsCompilation: | yes |
Packaged: | 2025-07-09 12:09:22 UTC; User |
Author: | Nasya Zahira Putri [aut, cre], Cucu Sumarni [aut] |
Repository: | CRAN |
Date/Publication: | 2025-07-14 17:00:06 UTC |
The 'saeHB.TF.beta' package.
Description
Small Area Estimation using Hierarchical Bayes Twofold Subarea Level Model under Beta Distribution
References
Stan Development Team (NA). RStan: the R interface to Stan. R package version 2.36.0.9000. https://mc-stan.org
Small Area Estimation using Hierarchical Bayes Twofold Subarea Level Model under Beta Distribution
Description
Function betaTF
used for estimation of subarea and area means simultaneously under Twofold Subarea Level Small Area Estimation Model Using Hierarchical Bayesian Method with Beta distribution
The range of data must be 0<y<1
.
Usage
betaTF(
formula,
area,
weight,
iter.update = 3,
iter.mcmc = 1000,
coef = NULL,
var.coef = NULL,
thin = 1,
burn.in = floor(iter.mcmc/2),
sigma2.u = 1,
sigma2.v = 1,
data
)
Arguments
formula |
Formula that describe the fitted model |
area |
Index that describes the code relating to area in each subarea.This should be defined for aggregation to get area estimator. Index start from 1 until m |
weight |
Vector contain proportion units or proportion of population on each subarea. |
iter.update |
Number of updates perform ( default = |
iter.mcmc |
Number of total iterations per chain (default = |
coef |
Vector contains prior initial value of Coefficient of Regression Model for fixed effect with default vector of |
var.coef |
Vector contains prior initial value of variance of Coefficient of Regression Model for fixed effect with default vector of |
thin |
Thinning rate, must be a positive integer |
burn.in |
Number of iterations to discard at the beginning |
sigma2.u |
Number of prior initial value of variance of subarea random effect |
sigma2.v |
Number of prior initial value of variance of area random effect |
data |
The data frame |
Value
This function returns a list with following objects:
Est_sub |
A dataframe contains the values, standard deviation, and quantile of Subarea mean Estimates using Twofold Subarea level model under Hierarchical Bayes method |
Est_area |
A dataframe contains the values, standard deviation, and quantile of Area mean Estimates using Twofold Subarea level model under Hierarchical Bayes method |
area_randeff |
A dataframe contains area random effect |
sub_randeff |
A dataframe contains subarea random effect |
refVar |
A dataframe that contains estimated subarea and area random effect variance |
coefficient |
A dataframe that contains the estimated model coefficient |
plot |
Trace, Density, Autocorrelation Function Plot of coefficient |
Examples
fit <- betaTF(y~X1+X2,area="codearea",weight="w",data=dataBeta, iter.mcmc = 500)
Simulated dataset Under Two Fold Subarea level model with Beta distribution.
Description
A dataset to simulate Small Area Estimation using Hierarchical Bayesian method under Two Fold Subarea level model with Beta distribution on variable interest.
This data is generated by these following steps:
Generate auxiliary variable
X_{ij1},X_{ij2}
, sampling errore_{ij}
,subarea random effectu_{ij}
, area random effectv_{i}
, and weight or proportions of unitw_{ij}
Generate auxiliary variable on subarea level
X_{ij1}
~U(0,1)
Generate auxiliary variable on subarea level
X_{ij2}
~N(0,1)
Setting coefficient
\beta_{0}=\beta_{1}=\beta_{2} =0.5
Generate area random effect
v_{i}
~N(0,1)
Generate subarea random effect
u_{ij}
~N(0,1)
Calculate target parameter
\mu_{ij}=\beta_{0} +\beta_{1}x_{ij1} +\beta_{2}x_{ij2}+v_{i}+u_{ij}
Generate constant for Beta parameter
\pi_{ij}
~Gamma(1,0.5)
Calculate Beta parameter
A=\mu_{ij}\pi_{ij}
andA=(1-\mu_{ij})\pi_{ij}
Generate direct estimator
y_{ij}
~Beta(A,B)
Generate weight on each subarea
w_{ij}
~U(0.2,0.7)
Direct estimation (
y_{ij}
), Auxiliary variablesX_{ij1}
,X_{ij2}
, vardir, codearea, and weightw_{ij}
are combined in a dataframe called dataBeta
Usage
dataBeta
Format
A data frame with 90 rows and 6 columns:
- y
Direct estimation of subarea mean
y_{ij}
- X1
Auxiliary variable of
X_{ij1}
- X2
Auxiliary variable of
X_{ij2}
- codearea
Index that describes the code relating to area for each subarea
- w
Unit proportion on each subarea or weight
w_{ij}
- vardir
Sampling variance of direct estimator
y_{ij}
Simulated dataset Under Two Fold Subarea level model with Beta distribution and Non-Sampled subarea.
Description
A dataset to simulate Small Area Estimation using Hierarchical Bayesian method under Two Fold Subarea level model with Beta distribution and Non-sampled subarea
This data contains NA values that indicates no sampled at one or more Subareas. It uses the
dataBeta
with the direct estimates and the related variances in 5 subareas are missing.
Usage
dataBetaNS
Format
A data frame with 90 rows and 6 columns:
- y
Direct estimation of subarea mean
y_{ij}
- X1
Auxiliary variable of
X_{ij1}
- X2
Auxiliary variable of
X_{ij2}
- codearea
Index that describes the code relating to area for each subarea
- w
Unit proportion on each subarea or weight
w_{ij}
- vardir
Sampling variance of direct estimator
y_{ij}