Skip to main content
v2026.11,986 entries · CC-BY 4.0

R-INLA: Install, Fit Models and Read the Output

R-INLA explained: what the package does, the install commands by R version, a worked inla() call, how to read summary output, and free alternatives.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

R-INLA is an R package for fast, approximate Bayesian inference for latent Gaussian models. It implements the integrated nested Laplace approximation (INLA), and you fit models with a single function, inla(), using a formula much like the one you would give to glm(). It is not distributed through CRAN: you install it from the project’s own repository, as shown below. This guide covers what it is for, the install commands for each R version, a worked model call, how to read the summary, the install problems the project documents, and the free alternatives.

What R-INLA is used for in research

The project’s home page describes the package as “a powerful R package designed to perform fast, approximate Bayesian inference for Latent Gaussian Models”. In practice that family covers the models research groups most often fit with a Bayesian workflow: generalized linear models with random effects, spatial and spatio-temporal models, and survival or longitudinal models. If you want the background on the modelling idea first, read the CASRAI guides on Bayesian regression and Bayesian hierarchical models; for the simulation-based route that INLA is usually compared with, see Markov chain Monte Carlo.

The R-INLA website lists worked tutorials that show the range of use. They are summarised here by what each one demonstrates, with the level the site assigns.

Tutorial topic Model type Level on the site
Salamander mating Generalized linear mixed model Beginner
Bivariate meta-analysis of sensitivity and specificity Bivariate meta-analysis Intermediate
Dengue in Brazil Non-stationary spatial model (fbesag) Intermediate
School disparities in Brunei Spatial model Advanced
Joint longitudinal and spatial event-time analysis Joint model Advanced

Each tutorial walks through data preparation, model specification, priors, diagnostics and interpretation, so the beginner example is a sensible first project before you attempt a spatial model. The site also points to two books: Rue and Held on Gaussian Markov random fields, and Gómez-Rubio’s Bayesian Inference with INLA.

How to install or access R-INLA

Install only from the official download page. The stable release is installed from the project’s repository, with the CRAN repository kept alongside it so that dependencies resolve:

install.packages("INLA", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"), dep = TRUE)

The testing release uses the same command with https://inla.r-inla-download.org/R/testing as the repository. Once installed, inla.upgrade() updates the stable build and inla.upgrade(testing = TRUE) updates the testing build. The download page recommends R 4.4 or later.

Choosing the INLA version for your R version

If you are stuck on an older R, install a version built for it with remotes::install_version(). For R 4.5 the download page gives this command, and the data table below lists the INLA version the page names for each R release from 4.1 to 4.5:

remotes::install_version("INLA", version = "25.04.29", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/testing"), dep = TRUE)

From INLA version 23.08.18 the package depends on fmesher, which you can install from CRAN with install.packages("fmesher").

How to fit a model in R-INLA step by step

The example below follows the surgical-mortality hospital model in Paula Moraga’s Spatial Statistics for Data Science, which fits a binomial model with a random effect per hospital. Adapt the variable names to your own data.

  1. Install the package as above and load it with library(INLA).
  2. Put your data in a data frame with one row per observation. The response, the number of trials (for binomial data) and any grouping variable are columns.
  3. Write the model formula. Fixed effects are written as in any R formula; each random or structured effect goes inside f(), whose first argument is the index variable and whose second is the model name. The book’s example is formula = r ~ f(hospital, model = "iid", hyper = prior.prec), where hyper carries the prior on the precision hyperparameter.
  4. Call inla() with the formula, the data and the likelihood family. The book’s call is res = inla(formula, data = Surg, family = "binomial", Ntrials = n, control.predictor = list(compute = TRUE), control.compute = list(dic = TRUE, return.marginals.predictor = TRUE)).
  5. Inspect the result with summary(res), then pull out the marginal distributions you need, as described in the next section.

The control.compute argument decides which extra quantities are computed: in the example it requests the deviance information criterion (DIC) and the marginals of the linear predictor. control.predictor = list(compute = TRUE) asks for the fitted values.

Three details of the example are worth understanding before you reuse it. First, the family argument sets the likelihood; the example uses "binomial" because the response is a count of events out of a number of trials, which is why Ntrials is supplied. Second, the model name inside f() chooses the structure of the random effect: the example uses "iid", meaning independent effects per hospital, whereas the tutorials on the R-INLA site use other model names for spatial structures. Third, anything you want back from the fit, such as DIC or marginals of the predictor, has to be requested through the control.* arguments, so decide what you need to report before you run the model.

How to read the R-INLA output

summary(res) is organised in blocks, and the book’s reading of each is as follows.

  • Fixed effects. One row per fixed effect with its mean, standard deviation, quantiles and mode, plus kld, the symmetric Kullback-Leibler divergence between the Gaussian and Laplace approximations of that posterior marginal.
  • Random effects and hyperparameters. Summaries for the model components declared with f() and for their hyperparameters, such as precisions.
  • Model-fit lines. The deviance information criterion, the effective number of parameters and the marginal log-likelihood, available because the example requested dic = TRUE.

Posterior marginals are stored as named lists whose elements are two-column matrices: the first column holds the value, the second the posterior density at that value. R-INLA ships helper functions for working with these marginals, inla.smarginal, inla.qmarginal, inla.pmarginal and inla.emarginal, so so the raw matrices are usually not handled directly. Report the marginal summaries you used and the priors you chose, since the priors in an INLA model are specified explicitly in the formula.

What to record for reproducibility

Because the INLA build you can install depends on your R release, a methods section should state both the R version and the INLA version used, along with the likelihood family, the model names passed to f() and the priors. Anyone replicating the analysis can then use the version-specific install command above to obtain the same build, instead of whatever the stable repository serves on the day they run it. The data table below the article lists the pairings the download page names, which you can use to check that your combination is one the project documents.

Troubleshooting R-INLA

  • The install fails or the package will not load on an older R. Use the version-specific remotes::install_version() command for your R release (see the data table below).
  • A dependency is missing after install. From INLA 23.08.18, install fmesher. The download page also notes that the Bioconductor packages graph and Rgraphviz are installed through BiocManager.
  • Windows reinstall problems. The download page says you may need to uninstall INLA before reinstalling it.
  • A binary does not run on your Linux system. The download page offers alternative Linux builds through inla.binary.install().
  • You need to move to a newer build. Run inla.upgrade() for stable or inla.upgrade(testing = TRUE) for testing.

For modelling questions rather than installation ones, the project’s Support and Issues section on its site is the place to look.

Free alternatives to R-INLA

Two R packages come up most often next to R-INLA, and they relate to it differently: one builds on it, one is a separate approach. Details are from each package’s CRAN page, checked 2026-11-18.

Package Relationship to R-INLA What its CRAN page says CRAN version
inlabru Built on INLA “Facilitates spatial and general latent Gaussian modelling using integrated nested Laplace approximation via the INLA package”; INLA is a suggested package (version 23.01.31 or later); requires R 4.1.0 or later 2.15.0 (published 2026-07-28)
brms Separate approach, uses Stan “Fit Bayesian generalized (non-)linear multivariate multilevel models using ‘Stan’ for full Bayesian inference” 2.23.0 (published 2025-09-09)

If your model is one of the multilevel types brms covers, the Stan-based route is a direct alternative; see the CASRAI guide to generalized linear mixed models for the surrounding concepts, and free statistical software for a wider survey. If you are new to R itself, start with how to use RStudio.

Sources

Data: INLA version named on the R-INLA download page for each R release

Version-specific installation targets for the INLA R package, compiled from the official R-INLA download page: the R release and the INLA version the page names for it.

Period covered: 2022/2025.

INLA version named on the R-INLA download page for each R release
R releaseINLA version named on the download page
R 4.525.04.29
R 4.424.05.10
R 4.323.05.30
R 4.222.05.07
R 4.122.05.03

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about R-INLA: Install, Fit Models and Read the Output

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →