Type: | Package |
Title: | Basic Unit Level Model using Hierarchical Bayesian Approach |
Version: | 0.1.0 |
Maintainer: | Ridson Al Farizal P <alfrzlp@gmail.com> |
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>. |
License: | MIT + file LICENSE |
URL: | https://github.com/Alfrzlp/saeHB.unit |
BugReports: | https://github.com/Alfrzlp/saeHB.unit/issues |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | cli, coda, dplyr, graphics, methods, rjags, stats |
RoxygenNote: | 7.2.0 |
Depends: | R (≥ 3.60) |
SystemRequirements: | JAGS (http://mcmc-jags.sourceforge.net) |
NeedsCompilation: | no |
Packaged: | 2023-10-14 01:38:02 UTC; alfrz |
Author: | Ridson Al Farizal P [aut, cre, cph], Azka Ubaidillah [aut] |
Repository: | CRAN |
Date/Publication: | 2023-10-15 08:10:02 UTC |
Create a complete ggplot appropriate to a particular data type
Description
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.
Usage
autoplot(object, ...)
Arguments
object |
an object, whose class will determine the behaviour of autoplot |
... |
other arguments passed to specific methods |
Value
a ggplot object
See Also
autolayer()
, ggplot()
and fortify()
Autoplot
Description
Autoplot
Usage
## S3 method for class 'saehb'
autoplot(object, ...)
Arguments
object |
HB model |
... |
other argument |
Value
plot
Examples
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)
Corn and soy beans survey and satellite data in 12 counties in Iowa
Description
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.
Usage
cornsoybean
Format
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.
Details
cornsoybean
Source
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.
Corn and soy beans mean number of pixels per segment for 12 counties in Iowa.
Description
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
.
Usage
cornsoybeanmeans
Format
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.
Details
cornsoybeanmeans
Source
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_area
Description
dummy data
Usage
dummy_area
Format
A data frame with 30 observations on the following 4 variables.
domain
:domain code
x1
:x1
x2
:x2
parameter
:true value of y
Details
dummy_area
dummy_unit
Description
dummy data
Usage
dummy_unit
Format
A data frame with 1000 observations on the following 4 variables.
domain
:domain code
y_di
:direct estimate of y
x1
:x1
x2
:x2
Details
dummy_unit
Basic Unit Level Model (Battese-Harter-Fuller model) using Hierarchical Bayesian Approach
Description
This function gives the Hierarchical Bayesian (HB) based on a basic unit level model (Battese-Harter-Fuller model).
Usage
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
)
Arguments
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). |
Value
The function returns a list with the following objects : Estimation Est
, random effect variance refVar
, beta coefficient Coefficient
and MCMC result result_mcmc
References
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.
Examples
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
Description
Summary sae HB model
Usage
## S3 method for class 'saehb'
summary(object, ...)
Arguments
object |
sae HB model |
... |
further arguments passed to or from other methods. |
Value
The function return a data.frame
of beta coefficient from HB model.
Examples
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)