Description Usage Arguments Value Author(s) Examples
Laplace Approximation of the normalizing constant
1 | normConstLaplace(sample, fLogPost, alpha = 0.05, nd = cov.rob(sample))
|
sample |
MCMC sample of parameters, each row of the matrix is a parameter vector |
fLogPost |
function to evaluate log of unnormalized posterior density |
alpha |
quantile defining the multivariate normal ellipsoid for volume correction |
nd |
normal density approximation: list with entries center and cov |
a list with estimates of the logs of the normalizing constant of the posterior
logCL |
Laplace estimate |
logCLV |
volume corrected Laplace estimate |
Thomas Wutzler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | mu = c(0,0)
sd = c(1,2)
corr = diag(nrow=2)
corr[1,2] <- corr[2,1] <- 0.49
Sigma = diag(sd, nrow=length(sd)) %*% corr %*% diag(sd,nrow=length(sd))
n <- 1000
cTrue <- 10
sample <- mvtnorm::rmvnorm(n,mean=mu,sigma=Sigma)
fPost <- function(theta){ cTrue* mvtnorm::dmvnorm(theta,mean=mu,sigma=Sigma, log=FALSE)}
fLogPost <- function(theta){ log(cTrue) + mvtnorm::dmvnorm(theta,mean=mu,sigma=Sigma, log=TRUE)}
exp(normConstLaplace( sample, fLogPost ))
#normd <- cov.rob(sample)
#(res <- boot( sample, function(sample, i){normConstLaplace(sample[i,], fLogDen=fLogDen, nd=normd)}, 100))
#(res2 <- boot( sample, function(sample, i){normConstLaplace(sample[i,], fLogDen=fLogDen)}, 100))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.