Title: | Basic Unit Level Model using Hierarchical Bayesian Approach |
---|---|
Description: | Small area estimation unit level models (Battese-Harter-Fuller model) with a Bayesian Hierarchical approach. See also Rao & Molina (2015, ISBN:978-1-118-73578-7) and Battese et al. (1988) <doi:10.1080/01621459.1988.10478561>. |
Authors: | Ridson Al Farizal P [aut, cre, cph], Azka Ubaidillah [aut] |
Maintainer: | Ridson Al Farizal P <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-12-08 06:51:31 UTC |
Source: | CRAN |
autoplot()
uses ggplot2 to draw a particular plot for an object of a
particular class in a single command. This defines the S3 generic that
other classes and packages can extend.
autoplot(object, ...)
autoplot(object, ...)
object |
an object, whose class will determine the behaviour of autoplot |
... |
other arguments passed to specific methods |
a ggplot object
autolayer()
, ggplot()
and fortify()
Autoplot
## S3 method for class 'saehb' autoplot(object, ...)
## S3 method for class 'saehb' autoplot(object, ...)
object |
HB model |
... |
other argument |
plot
library(dplyr) Xarea <- cornsoybeanmeans %>% dplyr::select( County = CountyIndex, CornPix = MeanCornPixPerSeg, SoyBeansPix = MeanSoyBeansPixPerSeg ) corn_model <- hb_unit( CornHec ~ SoyBeansPix + CornPix, data_unit = cornsoybean, data_area = Xarea, domain = "County", iter.update = 20, plot = FALSE ) autoplot(corn_model)
library(dplyr) Xarea <- cornsoybeanmeans %>% dplyr::select( County = CountyIndex, CornPix = MeanCornPixPerSeg, SoyBeansPix = MeanSoyBeansPixPerSeg ) corn_model <- hb_unit( CornHec ~ SoyBeansPix + CornPix, data_unit = cornsoybean, data_area = Xarea, domain = "County", iter.update = 20, plot = FALSE ) autoplot(corn_model)
Survey and satellite data for corn and soy beans in 12 Iowa counties, obtained from the 1978 June Enumerative Survey of the U.S. Department of Agriculture and from land observatory satellites (LANDSAT) during the 1978 growing season.
cornsoybean
cornsoybean
A data frame with 37 observations on the following 5 variables.
County
:numeric county code.
CornHec
:reported hectares of corn from the survey.
SoyBeansHec
:reported hectares of soy beans from the survey.
CornPix
:number of pixels of corn in sample segment within county, from satellite data.
SoyBeansPix
:number of pixels of soy beans in sample segment within county, from satellite data.
cornsoybean
Battesse, G.E., Harter, R.M. and Fuller, W.A. (1988). An Error-Components Model for Prediction of County Crop Areas Using Survey and Satellite Data. Journal of the American Statistical Association 83, 28-36.
County means of number of pixels per segment of corn and soy beans, from satellite data, for 12 counties in Iowa. Population size, sample size and means of auxiliary variables in data set cornsoybean
.
cornsoybeanmeans
cornsoybeanmeans
A data frame with 12 observations on the following 6 variables.
CountyIndex
:numeric county code.
CountyName
:name of the county.
SampSegments
:number of sample segments in the county (sample size).
PopnSegments
:number of population segments in the county (population size).
MeanCornPixPerSeg
:mean number of corn pixels per segment in the county.
MeanSoyBeansPixPerSeg
:mean number of soy beans pixels per segment in the county.
cornsoybeanmeans
Battesse, G.E., Harter, R.M. and Fuller, W.A. (1988). An Error-Components Model for Prediction of County Crop Areas Using Survey and Satellite Data. Journal of the American Statistical Association 83, 28-36.
dummy data
dummy_area
dummy_area
A data frame with 30 observations on the following 4 variables.
domain
:domain code
x1
:x1
x2
:x2
parameter
:true value of y
dummy_area
dummy data
dummy_unit
dummy_unit
A data frame with 1000 observations on the following 4 variables.
domain
:domain code
y_di
:direct estimate of y
x1
:x1
x2
:x2
dummy_unit
This function gives the Hierarchical Bayesian (HB) based on a basic unit level model (Battese-Harter-Fuller model).
hb_unit( formula, data_unit, data_area, domain, iter.update = 3, iter.mcmc = 10000, coef, var.coef, thin = 3, burn.in = 2000, tau.u = 1, seed = 1, quiet = TRUE, plot = TRUE )
hb_unit( formula, data_unit, data_area, domain, iter.update = 3, iter.mcmc = 10000, coef, var.coef, thin = 3, burn.in = 2000, tau.u = 1, seed = 1, quiet = TRUE, plot = TRUE )
formula |
an object of class formula that contains a description of the model to be fitted. The variables included in the formula must be contained in the data. |
data_unit |
data frame containing the variables named in |
data_area |
data frame containing the variables named in |
domain |
Character or formula for domain column names in unit data |
iter.update |
Number of updates with default 3 |
iter.mcmc |
Number of total iterations per chain with default 10000 |
coef |
a vector contains prior initial value of Coefficient of Regression Model for fixed effect with default vector of 0 with the length of the number of regression coefficients |
var.coef |
a vector contains prior initial value of variance of Coefficient of Regression Model with default vector of 1 with the length of the number of regression coefficients |
thin |
Thinning rate, must be a positive integer with default 2 |
burn.in |
Number of iterations to discard at the beginning with default 2000 |
tau.u |
Prior initial value of inverse of Variance of area random effect with default 1 |
seed |
number used to initialize a pseudorandom number generator (default seed = 1). The random number generator method used is "base::Wichmann-Hill". |
quiet |
if TRUE, then messages generated during compilation will be suppressed (default TRUE). |
plot |
if TRUE, the autocorrelation, trace, and density plots will be generated (default TRUE). |
The function returns a list with the following objects : Estimation Est
, random effect variance refVar
, beta coefficient Coefficient
and MCMC result result_mcmc
Battese, G. E., Harter, R. M., & Fuller, W. A. (1988). An error-components model for prediction of county crop areas using survey and satellite data. Journal of the American Statistical Association, 83(401), 28-36.
Rao, J. N., & Molina, I. (2015). Small area estimation. John Wiley & Sons.
library(dplyr) Xarea <- cornsoybeanmeans %>% dplyr::select( County = CountyIndex, CornPix = MeanCornPixPerSeg, SoyBeansPix = MeanSoyBeansPixPerSeg ) corn_model <- hb_unit( CornHec ~ SoyBeansPix + CornPix, data_unit = cornsoybean, data_area = Xarea, domain = "County", iter.update = 20 )
library(dplyr) Xarea <- cornsoybeanmeans %>% dplyr::select( County = CountyIndex, CornPix = MeanCornPixPerSeg, SoyBeansPix = MeanSoyBeansPixPerSeg ) corn_model <- hb_unit( CornHec ~ SoyBeansPix + CornPix, data_unit = cornsoybean, data_area = Xarea, domain = "County", iter.update = 20 )
Summary sae HB model
## S3 method for class 'saehb' summary(object, ...)
## S3 method for class 'saehb' summary(object, ...)
object |
sae HB model |
... |
further arguments passed to or from other methods. |
The function return a data.frame
of beta coefficient from HB model.
library(dplyr) Xarea <- cornsoybeanmeans %>% dplyr::select( County = CountyIndex, CornPix = MeanCornPixPerSeg, SoyBeansPix = MeanSoyBeansPixPerSeg ) corn_model <- hb_unit( CornHec ~ SoyBeansPix + CornPix, data_unit = cornsoybean, data_area = Xarea, domain = "County", iter.update = 20 ) summary(corn_model)
library(dplyr) Xarea <- cornsoybeanmeans %>% dplyr::select( County = CountyIndex, CornPix = MeanCornPixPerSeg, SoyBeansPix = MeanSoyBeansPixPerSeg ) corn_model <- hb_unit( CornHec ~ SoyBeansPix + CornPix, data_unit = cornsoybean, data_area = Xarea, domain = "County", iter.update = 20 ) summary(corn_model)