Learn R Programming

agfh

Overview

Small area statistics concerns estimation techniques for sub-populations when direct estimation would be unreliable. The agfh package implements the Agnostic Fay-Herriot model (AGFH), an extension of the traditional small area model. In place of normal sampling errors, the sampling error distribution is modified by a Gaussian process to accommodate a broader class of distributions.

This flexibility is most useful in the presence of bounded, bi-modal, or heavily skewed sampling errors. Practitioners should consider the AGFH model when they have evidence of such departures from the traditional methods

Installation

Install the official version from CRAN:

install.packages('agfh')

Next, consult the accompanying paper for a thorough background (under review), or the vignette within this package for an end-to-end illustration of the package.

Getting Started

The AGFH model is implemented as a Metropolis-within-Gibbs sampler; use make_agfh_sampler() to instantiate a sampler. Doing so requires supplying the observed response (as an -vector of univariate values), accompanying covariates (as an matrix of values), and sampling error precision (again an -vector of univariate values). Additionally, prior hyperparameters can be supplied.

make_agfh_sampler() creates a sampler function; calling it will produce MCMC samples targeting the posterior. It requires starting values for the Gibbs components as well as the desired number of steps and thinning rate. Note, n.mcmc=100 and n.thin=10 would make 1000 MCMC steps and return every tenth.

The sampler returns a list of relevant samples and summary values. Typically, the contents of param.samples.list are most interesting; these are the posterior samples from the AGFH model. The convenience method map_from_density() may be used to get a maximum a posteriori point estimate.

Parallel analysis with the traditional Fay-Herriot model is also possible with agfh, as detailed in the vignette. In particular, make_gibbs_sampler() returns a Gibbs sampler of the traditional model that can be used in the same manner as make_agfh_sampler().

Copy Link

Version

Install

install.packages('agfh')

Monthly Downloads

355

Version

0.2.1

License

GPL (>= 3)

Maintainer

Marten Thompson

Last Published

June 21st, 2023

Functions in agfh (0.2.1)

mse

Calculate the Mean Squared Error Between two Vectors
null_gen

Generate Data with Normal Sampling Errors
test_u_normal

Normality Test
make_gibbs_sampler

Maker Function: Traditional Fay-Herriot Gibbs Sampler
map_from_density

Calculate the MAP Estimate from Posterior Samples
theta_var_est_grid

Basic Grid Optimizer for Likelihood
RM_theta_new_pred

Traditional EBLUP Estimator of Theta for new X values
RM_theta_eblup

Traditional EBLUP Estimator of Theta
adj_profile_likelihood_theta_var_maker

Maker Function: Adjusted Profile Likelihood of Latent Variance
adj_resid_likelihood_theta_var_maker

Maker Function: Adjusted Residual Likelihood of Latent Variance
beta_err_gen

Generate Data with Beta Sampling Errors
RM_beta_eblue

Traditional EBLUE Estimator of Beta
cramer_vonmises

Cramer-Von Mises Normality Test
RM_theta_var_moment_est

Moment-Based Estimator of Latent Model Variance
kolmogorov_smirnov

Kolmogorov-Smirnov Normality Test
shapiro_wilk

Shaprio-Wilk Normality Test
resid_likelihood_theta_var_maker

Maker Function: Residual Likelihood of Latent Variance
make_agfh_sampler

Maker Function: Agnostic Fay-Herriot Sampler
agfh_theta_new_pred

Agnostic Fay-Herriot Hierarchical Bayesian Model Predictions at Latent Level
anderson_darling

Anderson-Darling Normality Test
hb_theta_new_pred

Traditional Fay-Herriot Hierarchical Bayesian Model Predictions
gamma_err_gen

Generate Data with Gamma Sampling Errors