A Julia-native reimplementation of the latent Gaussian model / INLA stack originally provided by R-INLA. The goal is not line-by-line port but a composable, dispatch-based, SciML-aligned alternative that covers the mainstream use cases of R-INLA with native performance and genuine extensibility.
v1.1.0. The src/-bearing packages
(GMRFs.jl, LatentGaussianModels.jl, INLASPDE.jl,
INLASPDERasters.jl, LGMFormula.jl, LGMTuring.jl) cover the
canonical R-INLA datasets within the testing-strategy tolerances. See
CHANGELOG.md for what landed and where R-INLA parity
is known to be loose.
| Package | Purpose | Depends on |
|---|---|---|
GMRFs.jl |
Sparse Gaussian Markov random fields: graph, precision, sampling, conditioning, log-density. Standalone-useful. | SparseArrays, LinearSolve, Graphs, Distributions, ChainRulesCore |
LatentGaussianModels.jl |
LGM abstraction, latent components (IID/RW/AR1/Besag/BYM2/…), likelihoods, INLA inference. LogDensityProblems seam for downstream samplers. |
GMRFs, NonlinearSolve, Optimization, LogDensityProblems |
INLASPDE.jl |
SPDE–Matérn finite-element assembly on Meshes.jl triangulations. | LatentGaussianModels, Meshes, DelaunayTriangulation, CoordRefSystems |
Heavy integrations live outside the core to keep load times small and release cadences independent. Install whichever you need.
| Package | Purpose | Adds dep on |
|---|---|---|
LGMFormula.jl |
Tier-2 @lgm formula sugar over LatentGaussianModel(...). |
StatsModels |
LGMTuring.jl |
HMC/NUTS bridge for cross-validation and INLA-within-MCMC flows. | Turing, AdvancedHMC |
GMRFsPardiso.jl |
MKL / Panua Pardiso factorization backend for GMRFs.jl. License-gated. | Pardiso |
INLASPDERasters.jl |
Covariate extraction from rasters + raster prediction surfaces. | Rasters |
The umbrella package INLA.jl re-exports
GMRFs, LatentGaussianModels, and INLASPDE so that using INLA
brings the inference stack into scope in one import.
The packages are registered on a personal Julia registry at
haavardhvarnes/JuliaRegistry.
From a fresh Julia REPL:
using Pkg
Pkg.Registry.add(RegistrySpec(url = "https://github.com/haavardhvarnes/JuliaRegistry"))
Pkg.add("INLA") # umbrella: GMRFs + LatentGaussianModels + INLASPDEFor a leaner install, replace "INLA" with any individual core
package — "GMRFs", "LatentGaussianModels", "INLASPDE", or
"INLASPDERasters". INLASPDERasters ships a working raster–SPDE
bridge exercised end-to-end by the Meuse SPDE vignette; see its
README.
The optional sub-packages LGMTuring.jl, LGMFormula.jl, and
GMRFsPardiso.jl are not registered yet. Install them by
Pkg.develop-ing this repo's subdir directly:
Pkg.develop(url = "https://github.com/haavardhvarnes/INLA.jl",
subdir = "packages/LGMTuring.jl")- Latent components:
Intercept,FixedEffects,IID,RW1,RW2,AR1,Seasonal,Besag,BYM,BYM2,Leroux,Generic0,Generic1,SPDE2(α = 2 Matérn). - Likelihoods:
Gaussian,Poisson,Binomial,NegativeBinomial,Gamma— with closed-form gradients/Hessians for the inner Newton loop and a ForwardDiff fallback for user-defined cases. - Hyperpriors:
PCPrecision,GammaPrecision,LogNormalPrecision,WeakPrior,PCBYM2Phi,LogitBeta. - Inference strategies:
EmpiricalBayes(Laplace at θ̂),INLA(Laplace + θ-integration), and aLogDensityProblemsseam for external samplers —LGMTuring.jlprovides the NUTS bridge. - θ-integration schemes:
Grid,GaussHermite,CCD—int_strategy = :autochooses CCD for dim θ > 2, Grid otherwise. - Diagnostics: DIC, WAIC, CPO, PIT.
- Formula sugar (Phase N):
LGMFormula.jlships a Tier-2@lgmmacro for users coming from R-INLA'sinla(formula, …)API — source-to-source over the explicit constructor; see the migration guide.
Eleven R-INLA oracle fixtures (Scotland and Pennsylvania BYM2,
classical BYM, synthetic Gamma / Negative Binomial / Generic0 /
Generic1 / Seasonal / Leroux / disconnected Besag, Meuse SPDE) are
checked into the test suite, each with the R-INLA posterior summaries
and cpu.used wall-clock embedded.
The reproducer script at
bench/oracle_compare.jl runs every problem
end-to-end, prints a markdown table of relative errors and side-by-side
wall-clock seconds, and writes the full per-quantity comparison to
JSON. From the repo root:
julia --project=bench bench/oracle_compare.jlSee bench/README.md for column meanings, expected
runtime (~3-5 minutes), and the JSON schema.
plans/— ecosystem-level design documents (architecture, dependencies, testing, macro policy, ADR log).references/— annotated bibliography and notes on upstream INLA source.bench/— R-INLA parity reproducer (oracle_compare.jl) and its env.benchmarks/— performance harness (run.jl) timing INLA.jl vs R-INLA on the flagship datasets; results inbenchmarks/results/.docs/— Documenter site source (docs/src/); built site lives atdocs/build/(gitignored).scripts/— fixture generation and utilities.packages/— the Julia packages themselves, each with its own plan andCLAUDE.md.
See CLAUDE.md for the full set. Short version:
- Multiple dispatch is the primary extension mechanism. Macros are optional sugar, never semantics.
- Compose existing ecosystem packages rather than owning types — GeoInterface, Graphs, Meshes, Distributions, LinearSolve.
- Validation against R-INLA on canonical datasets is a first-class test tier, not an afterthought.
- SciML code style; weakdeps/extensions for optional integrations.
MIT (each package licensed independently, but all packages in the ecosystem use MIT).