| AdMitIS | R Documentation |
Performs importance sampling using an adaptive mixture of Student-t distributions as the importance density
AdMitIS(N = 1e5, KERNEL, G = function(theta){theta}, mit = list(), ...)
N |
number of draws used in importance sampling (positive
integer number). Default: |
KERNEL |
kernel function of the target density on which the
adaptive mixture of Student-t distributions is fitted. This
function should be vectorized for speed purposes (i.e., its first
argument should be a matrix and its output a vector). Moreover, the function must contain
the logical argument |
G |
function of interest used in importance
sampling (see *Details*). It is applied to the |
mit |
list containing information on the mixture approximation (see *Details*). |
... |
further arguments to be passed to |
The AdMitIS function estimates
E_p[g(\theta)], where p is the target
density, g is an (integrable w.r.t. p) function and E denotes
the expectation operator, by importance sampling using an adaptive
mixture of Student-t distributions as the importance density.
By default, the function G is given by:
G <- function(theta)
{
theta
}
and therefore, AdMitIS estimates the mean of
theta by importance sampling. For other definitions of
G, see *Examples*. Additional arguments required by G
are passed through ....
The argument mit is a list containing information on the
mixture approximation. The following components must be provided:
pvector (of length H) of mixing probabilities.
mumatrix (of size H \times d) containing
the vectors of modes (in row) of the mixture components.
Sigmamatrix (of size H \times d^2)
containing the scale matrices (in row) of the mixture components.
dfdegrees of freedom parameter of the Student-t
components (positive real number; AdMit itself fits
mixtures with df not smaller than one).
where H (\geq 1) is the number of components of the
adaptive mixture of Student-t distributions and
d (\geq 1) is the dimension of the first argument in KERNEL. Typically,
mit is estimated by the function AdMit.
A list with the following components:
ghat: a vector containing the importance sampling estimates.
NSE: a vector containing the numerical standard error of the components of ghat.
RNE: a vector containing the relative numerical efficiency of the
components of ghat. It is NA for a component of G
whose estimated variance is zero, that is, when NSE is zero and the
relative efficiency is undefined.
Further details and examples of the R package AdMit
can be found in Ardia, Hoogerheide, van Dijk (2009a,b).
Further information on importance sampling can be found in Geweke (1989) or Koop (2003).
Please cite the package in publications. Use citation("AdMit").
David Ardia
Ardia, D., Hoogerheide, L.F., van Dijk, H.K. (2009a). AdMit: Adaptive Mixture of Student-t Distributions. R Journal 1(1), pp.25-30. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32614/RJ-2009-003")}
Ardia, D., Hoogerheide, L.F., van Dijk, H.K. (2009b). Adaptive Mixture of Student-t Distributions as a Flexible Candidate Distribution for Efficient Simulation: The R Package AdMit. Journal of Statistical Software 29(3), pp.1-32. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v029.i03")}
Geweke, J.F. (1989). Bayesian Inference in Econometric Models Using Monte Carlo Integration. Econometrica 57(6), pp.1317-1339.
Koop, G. (2003). Bayesian Econometrics. Wiley-Interscience (London, UK). ISBN: 0470845678.
AdMit for fitting an adaptive mixture of Student-t
distributions to a target density through its KERNEL function,
AdMitMH for the independence chain Metropolis-Hastings
algorithm using an adaptive mixture of Student-t distributions
as the candidate density.
## NB : Low number of draws for speedup. Consider using more draws!
## Gelman and Meng (1991) kernel function
GelmanMeng <- function(x, A = 1, B = 0, C1 = 3, C2 = 3, log = TRUE)
{
if (is.vector(x))
x <- matrix(x, nrow = 1)
r <- -.5 * (A * x[,1]^2 * x[,2]^2 + x[,1]^2 + x[,2]^2
- 2 * B * x[,1] * x[,2] - 2 * C1 * x[,1] - 2 * C2 * x[,2])
if (!log)
r <- exp(r)
as.vector(r)
}
## Run the AdMit function to fit the mixture approximation
set.seed(1234)
outAdMit <- AdMit(KERNEL = GelmanMeng,
mu0 = c(0.0, 0.1),
control = list(Ns = 2e3, Np = 5e2, Hmax = 4))
## Use importance sampling with the mixture approximation as the
## importance density
outAdMitIS <- AdMitIS(N = 1e4, KERNEL = GelmanMeng, mit = outAdMit$mit)
print(outAdMitIS)
## A scalar-valued function of interest: E[theta_1^2]
G.square <- function(theta) theta[,1]^2
print(AdMitIS(N = 1e4, KERNEL = GelmanMeng, G = G.square, mit = outAdMit$mit))
## A matrix-valued function of interest, with an extra argument passed
## through '...': the posterior covariance matrix around 'mu'
G.cov <- function(theta, mu)
{
G.cov_sub <- function(x)
(x - mu) %*% t(x - mu)
theta <- as.matrix(theta)
tmp <- apply(theta, 1, G.cov_sub)
if (length(mu) > 1)
t(tmp)
else
as.matrix(tmp)
}
outAdMitIS <- AdMitIS(N = 1e4, KERNEL = GelmanMeng, G = G.cov,
mit = outAdMit$mit, mu = c(1.459, 1.459))
print(matrix(outAdMitIS$ghat, 2, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.