R: Importance Sampling using an Adaptive Mixture of Student-t...
AdMitIS
R Documentation
Importance Sampling using an Adaptive Mixture of Student-t
Distributions as the Importance Density
Description
Performs importance sampling using an adaptive
mixture of Student-t distributions as the importance density
Usage
AdMitIS(N = 1e5, KERNEL, G = function(theta){theta}, mit = list(), ...)
Arguments
N
number of draws used in importance sampling (positive
integer number). Default: N = 1e5.
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 log. If log = TRUE, the function
returns (natural) logarithm values of the kernel function. NA
and NaN values are not allowed. (See the function
AdMit for examples of KERNEL implementation.)
G
function of interest used in importance
sampling (see *Details*).
mit
list containing information on the mixture approximation (see *Details*).
...
further arguments to be passed to KERNEL and/or G.
Details
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*.
The argument mit is a list containing information on the
mixture approximation. The following components must be provided:
p
vector (of length H) of mixing probabilities.
mu
matrix (of size Hxd) containing
the vectors of modes (in row) of the mixture components.
Sigma
matrix (of size Hxd*d)
containing the scale matrices (in row) of the mixture components.
df
degrees of freedom parameter of the Student-t
components (real number not smaller than one).
where H (>=1) is the number of components of the
adaptive mixture of Student-t distributions and
d (>=1) is the dimension of the first argument in KERNEL. Typically,
mit is estimated by the function AdMit.
Value
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.
Note
Further details and examples of the R package AdMit
can be found in Ardia, Hoogerheide, van Dijk (2009a,b). See also
the package vignette by typing vignette("AdMit") and the
files ‘AdMitJSS.txt’ and ‘AdMitRnews.txt’ in the ‘/doc’ package's folder.
Further information on importance sampling can be found
in Geweke (1989) or Koop (2003).
Please cite the package in publications. Use citation("AdMit").
Author(s)
David Ardia
References
Ardia, D., Hoogerheide, L.F., van Dijk, H.K. (2009a).
AdMit: Adaptive Mixture of Student-t Distributions.
The R Journal1(1), pp.25–30.
http://journal.r-project.org/2009-1/
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 Software29(3), pp.1–32.
http://www.jstatsoft.org/v29/i03/
Geweke, J.F. (1989).
Bayesian Inference in Econometric Models Using Monte Carlo Integration.
Econometrica57(6), pp.1317–1339.
Koop, G. (2003).
Bayesian Econometrics.
Wiley-Interscience (London, UK). ISBN: 0470845678.
See Also
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.
Examples
## 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 = 1e4))
## Use importance sampling with the mixture approximation as the
## importance density
outAdMitIS <- AdMitIS(N = 1e4, KERNEL = GelmanMeng, mit = outAdMit$mit)
print(outAdMitIS)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(AdMit)
Loading required package: mvtnorm
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/AdMit/AdMitIS.Rd_%03d_medium.png", width=480, height=480)
> ### Name: AdMitIS
> ### Title: Importance Sampling using an Adaptive Mixture of Student-t
> ### Distributions as the Importance Density
> ### Aliases: AdMitIS
> ### Keywords: htest
>
> ### ** Examples
>
> ## 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 = 1e4))
>
> ## Use importance sampling with the mixture approximation as the
> ## importance density
> outAdMitIS <- AdMitIS(N = 1e4, KERNEL = GelmanMeng, mit = outAdMit$mit)
> print(outAdMitIS)
$ghat
[1] 1.460665 1.464593
$NSE
[1] 0.01529548 0.01551707
$RNE
[1] 0.6447638 0.6384846
>
>
>
>
>
> dev.off()
null device
1
>