EntropyMCMC {EntropyMCMC} | R Documentation |
Kullback and entropy estimation from MCMC simulation output - single and multicore versions
Description
These functions return estimates of the entropy
of the density p^t
of a MCMC algorithm at time t
,
E_{p^t}[\log(p^t)]
,
and of the Kullback divergence between p^t
and the target density,
for t=1
up to the number of iterations that have been simulated.
The MCMC simulations must be computed before or externally,
and passed as a "plMCMC
" object
in the first argument (see details).
The target may be known only up to a multiplicative constant (see details).
EntropyMCMC.mc
is a parallel computing
version that uses the
parallel package to split the task between the available (virtual) cores on the computer. This version using socket cluster is not available for Windows computers.
Usage
EntropyMCMC(plmc1, method = "A.Nearest.Neighbor", k=1, trim = 0.02, eps=0,
all.f = TRUE, verb = FALSE, EntVect = FALSE,
uselogtarget = FALSE, logtarget = NULL)
EntropyMCMC.mc(plmc1, method = "A.Nearest.Neighbor", k = 1, trim = 0.02, eps=0,
all.f = TRUE, verb = FALSE, EntVect = FALSE, nbcores=detectCores(),
uselogtarget = FALSE, logtarget = NULL)
Arguments
plmc1 |
an objects of class |
method |
The method for estimating the entropy |
k |
The k-nearest neighbor index, the default is |
trim |
Parameter controlling the percentage of smallest data from one subsample
that is removed, only for |
eps |
A parameter controlling precision in the |
all.f |
If |
verb |
Verbose mode |
EntVect |
If |
nbcores |
Number of required (virtual) cores, defaults to all as returned
by |
uselogtarget |
Set to |
logtarget |
The function defining |
Details
Methods based on Nearest Neighbors (NN) should be preferred since these require less tuning parameters.
Some options, as uselogtarget
are in testing phase and are not implemented in all the available methods (see Arguments).
Value
An object of class KbMCMC
(for Kullback MCMC), containing:
Kullback |
A vector of estimated divergences |
Entp |
A vector of estimated entropies |
nmc |
The number of iid copies of each single chain. |
dim |
The state space dimension of the MCMC algorithm. |
algo |
The name of the MCMC algorithm that have been used to simulate
the copies of chains, see |
target |
The target density for which the MCMC algorithm is defined;
ususally given only up to a multiplicative constant for MCMC in Bayesian models.
target must be a function such as the multidimensional gaussian
|
method |
The |
f_param |
A list holding all the necessary target parameters, consistent with the target definition. |
q_param |
A list holding all the necessary parameters for the proposal density of the MCMC algorithm that have been used. |
Note
The method "Resubst"
is implemented for testing, without theoretical guarantee of convergence.
Author(s)
Didier Chauveau, Houssam Alrachid.
References
Chauveau, D. and Vandekerkhove, P. (2013), Smoothness of Metropolis-Hastings algorithm and application to entropy estimation. ESAIM: Probability and Statistics, 17, 419–431. DOI: http://dx.doi.org/10.1051/ps/2012004
Chauveau D. and Vandekerkhove, P. (2014), Simulation Based Nearest Neighbor Entropy Estimation for (Adaptive) MCMC Evaluation, In JSM Proceedings, Statistical Computing Section. Alexandria, VA: American Statistical Association. 2816–2827.
Chauveau D. and Vandekerkhove, P. (2014), The Nearest Neighbor entropy estimate: an adequate tool for adaptive MCMC evaluation. Preprint HAL http://hal.archives-ouvertes.fr/hal-01068081.
See Also
MCMCcopies
and
MCMCcopies.mc
for iid MCMC simulations (single core and multicore),
EntropyParallel
and EntropyParallel.cl
for simultaneous simulation and entropy estimation (single core and multicore).
Examples
## Toy example using the bivariate gaussian target
## with default parameters value, see target_norm_param
n = 150; nmc = 50; d=2 # bivariate example
varq=0.1 # variance of the proposal (chosen too small)
q_param=list(mean=rep(0,d),v=varq*diag(d))
## initial distribution, located in (2,2), "far" from target center (0,0)
Ptheta0 <- DrawInit(nmc, d, initpdf = "rnorm", mean = 2, sd = 1)
# simulation of the nmc iid chains, singlecore
s1 <- MCMCcopies(RWHM, n, nmc, Ptheta0, target_norm,
target_norm_param, q_param, verb = FALSE)
summary(s1) # method for "plMCMC" object
e1 <- EntropyMCMC(s1) # computes Entropy and Kullback divergence estimates
par(mfrow=c(1,2))
plot(e1) # default plot.plMCMC method, convergence after about 80 iterations
plot(e1, Kullback = FALSE) # Plot Entropy estimates over time
abline(normEntropy(target_norm_param), 0, col=8, lty=2) # true E_f[log(f)]