INLA (contributed functions)

Integrated Nested Laplace Approximation

R-INLA is an R package that implements Integrated Nested Laplace Approximation (INLA), a method to perform approximate Bayesian analysis for a wide class of model specifications, including hierarchical regression models and spatial or spatio-temporal models.

The idea underlying INLA is that, instead of performing computation for the posterior or predictive distributions using MCMC (which is generally very effective, but can be very computationally intensive, especially for complex models or very large datasets), in a specific class of models in which the prior distribution for the (vector of) parameter(s) is characterised by Gaussian Random Markov Fields, these tasks can be performed using approximations based on Laplace methods. This in turn produces reliable inference with massive improvements in computational time.

The papers linked here give detailed information on INLA. This is a tutorial on INLA for spatio- and spatio-temporal models (which I co-wrote). This is a presentation I prepared (drawing on material by HÃ¥vard Rue), for the Bayes Pharma 2013 workshop, in Rotterdam.

I have written a function, which can be used to express the uncertainty in the structured (“random”) effects of an INLA model in terms of the standard deviation, instead of the precision (which INLA gives by default - see here and here for a couple of entries on the blog on this). is available in the latest development version of R-INLA. Assuming that the package is installed, this version can be obtained by typing


in the R session.

Given a the output of the call to the inla function (which uses INLA to fit the model specified by the user), say the R object m, it is possible to run

s <-

to obtain an object s containing the following elements

  • s$hyper: a table with the summary of the standard deviations for the structured effects
  • s$samples: the simulated values from the posterior distributions on the standard deviation scale, which can be used for example to draw a histogram or other summaries

Currently, only works for hierarchical models (i.e. not for spatially or spatio-temporally structured models)