normConstLaplace: normConstLaplace

Description Usage Arguments Value Author(s) Examples

Description

Laplace Approximation of the normalizing constant

Usage

1
normConstLaplace(sample, fLogPost, alpha = 0.05, nd = cov.rob(sample))

Arguments

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

Value

a list with estimates of the logs of the normalizing constant of the posterior

logCL

Laplace estimate

logCLV

volume corrected Laplace estimate

Author(s)

Thomas Wutzler

Examples

 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))

twDEMC documentation built on May 2, 2019, 5:38 p.m.