Software Installation

Please use the instructions below to install and check your installation.

Since 29 April 2025, the latest INLA package is built for R 4.5, so if you’re able to upgrade your R installation, please do so to avoid unnecessary issues. The package will in many cases also work with older R versions, but compatibility is sometimes difficult.

Installing INLA and inlabru

Due to the work involved in building the binaries for the INLA package C software for different architectures, the INLA package is not on CRAN, but it can be installed from its own distribution repository.

  1. Check your R version.

  2. Install R-INLA, instructions can be found here

  3. Install inlabru (available from CRAN)

# Enable universe(s) by inlabru-org
options(repos = c(
  inlabruorg = "https://inlabru-org.r-universe.dev",
  INLA = "https://inla.r-inla-download.org/R/testing",
  CRAN = "https://cloud.r-project.org"
))

# Install some packages
install.packages("inlabru")
  1. Make sure you have the latest R-INLA, inlabru and R versions installed.

  2. Install the following libraries:

install.packages(c(
  "CARBayesdata",
  "dplyr",
  "fmesher",
  "ggplot2",
  "lubridate",
  "mapview",
  "patchwork",
  "scico",
  "sdmTMB",
  "sf",
  "spatstat",
  "spdep",
  "terra",
  "tidyr",
  "tidyterra",
  "viridis"
))

Installation check

Please check your installation using the basic model runs below.

If you run into issues, you can post a question with information about what you tried and what didn’t work, on the course github discussion page.

You can check that INLA is correctly installed by running

df <- data.frame(y = rnorm(100) + 10)
fit <- INLA::inla(
  y ~ 1,
  data = df
)
summary(fit)
Time used:
    Pre = 0.557, Running = 0.293, Post = 0.0686, Total = 0.919 
Fixed effects:
              mean    sd 0.025quant 0.5quant 0.975quant   mode kld
(Intercept) 10.033 0.097      9.841   10.033     10.224 10.033   0

Model hyperparameters:
                                        mean    sd 0.025quant 0.5quant
Precision for the Gaussian observations 1.07 0.151      0.798     1.06
                                        0.975quant mode
Precision for the Gaussian observations       1.39 1.05

Marginal log-Likelihood:  -151.18 
 is computed 
Posterior summaries for the linear predictor and the fitted values are computed
(Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')

If the simple inla() call fails with a crash, you may need to install different inla binaries for your hardware/software combination, with INLA::inla.binary.install().

When inla() works, you can check that inlabru is installed correctly by running the same model in inlabru:

fit <- inlabru::bru(
  y ~ Intercept(1, prec.linear = exp(-7)),
  data = df
)
summary(fit)
inlabru version: 2.13.0.9016 
INLA version: 25.08.21-1 
Components: 
Latent components:
Intercept: main = linear(1)
Observation models: 
  Family: 'gaussian'
    Tag: <No tag>
    Data class: 'data.frame'
    Response class: 'numeric'
    Predictor: y ~ .
    Additive/Linear: TRUE/TRUE
    Used components: effects[Intercept], latent[] 
Time used:
    Pre = 0.333, Running = 0.255, Post = 0.0819, Total = 0.669 
Fixed effects:
            mean    sd 0.025quant 0.5quant 0.975quant   mode kld
Intercept 10.032 0.097      9.841   10.032     10.224 10.032   0

Model hyperparameters:
                                        mean    sd 0.025quant 0.5quant
Precision for the Gaussian observations 1.07 0.151      0.798     1.06
                                        0.975quant mode
Precision for the Gaussian observations       1.39 1.05

Marginal log-Likelihood:  -155.65 
 is computed 
Posterior summaries for the linear predictor and the fitted values are computed
(Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')