Learn R Programming

iterLap (version 1.1-4)

GRApprox: Gelman-Rubin mode approximation

Description

Performs the multiple mode approximation of Gelman-Rubin (applies a Laplace approximation to each mode). The weights are determined corresponding to the height of each mode.

Usage

GRApprox(post, start, grad, method = c("nlminb", "nlm", "Nelder-Mead", "BFGS"),
         control = list(), ...)

Value

Produces an object of class mixDist. That a list mit entries

weights Vector of weights for individual components

means Matrix of component medians of components

sigmas List containing scaling matrices

eigenHess List containing eigen decompositions of scaling matrices

dets Vector of determinants of scaling matrix

sigmainv List containing inverse scaling matrices

Arguments

post

log-posterior density.

start

vector of starting values if dimension=1 otherwise matrix of starting values with the starting values in the rows

grad

gradient of log-posterior

method

Which optimizer to use

control

Control list for the chosen optimizer

...

Additional arguments for log-posterior density specified in post

Author

Bjoern Bornkamp

References

Gelman, A., Carlin, J. B., Stern, H. S. & Rubin, D. B. (2003) Bayesian Data Analysis, 2nd edition, Chapman and Hall. (Chapter 12)

Bornkamp, B. (2011). Approximating Probability Densities by Iterated Laplace Approximations, Journal of Computational and Graphical Statistics, 20(3), 656--669.

See Also

iterLap

Examples

Run this code

  ## log-density for banana example
  banana <- function(pars, b, sigma12){
    dim <- 10
    y <- c(pars[1], pars[2]+b*(pars[1]^2-sigma12), pars[3:dim])
    cc <- c(1/sqrt(sigma12), rep(1, dim-1))
    return(-0.5*sum((y*cc)^2))
  }

  start <- rbind(rep(0,10),rep(-1.5,10),rep(1.5,10))
  ## multiple mode Laplace approximation
  aa <- GRApprox(banana, start, b = 0.03, sigma12 = 100)
  ## print mixDist object
  aa
  ## summary method
  summary(aa)
  ## importance sampling using the obtained mixDist object 
  ## using a mixture of t distributions with 10 degrees of freedom
  dd <- IS(aa, nSim=1000, df = 10, post=banana, b = 0.03,
           sigma12 = 100)
  ## effective sample size
  dd$ESS

Run the code above in your browser using DataLab