This book grew out of a tutorial written by Elias T. Krainski, which he started in 2013 together with his PhD-studies at NTNU, Trondheim, Norway. The tutorial has since then been expanded continuously, based on response from the many users and based on new developments.

Lindgren, Rue, and Lindström (2011) describe an approximation to continuous spatial models with a Matérn covariance that is based on the solution to a stochastic partial differential equation (SPDE). This approximation is computed using a sparse representation that can be effectively implemented using the integrated nested Laplace approximation (INLA, Rue, Martino, and Chopin 2009).

This book will show you how to fit models that contain at least one effect specified with an SPDE using the INLA package for the R software for statistical computing. An SPDE based model will be used to define random effects over continuous domains in one or two dimensions. The usual application is data whose geographical location is explicitly considered in the analysis.

This book explores INLA functionalities through examples, and it is structured as follows. Chapter 1 provides an introduction to the integrated nested Laplace approximation and its associate INLA package for the R programming language. Chapter 2 introduces Gaussian random fields and the SPDE framework, develops an example on a toy dataset and works through some examples of building a mesh. Here, an example with non-Gaussian data is also discussed. Then three examples on the use of models with several likelihoods are developed in Chapter 3. These include a measurement error model, a coregionalization model and considering part or the entire linear predictor from one outcome in a linear predictor of another one. Point pattern analysis is included in Chapter 4 using a log-Gaussian Cox process. Non-stationary spatial models are developed in Chapter 5, which includes inclusion of covariates in the covariance parameters and barrier models. Chapter 6 focuses on survival analysis, and models for extremes and non-standard likelihoods are discussed here. Space-time models are described in detail in Chapter 7. Some applications of space-time models are developed in Chapter 8. Two appendices are included at the end with a summary of the notation used in the book and information about the R packages required to reproduce the examples in the book.

The introduction in Chapter 1 can be used as a starting point for the integrated nested Laplace approximation and the INLA package. Chapter 2 tries to explain some of the theoretical details behind the SPDE approach by developing two examples. Going through the more theoretical details may require some background on stochastic processes, but the applications of the SPDE approach are described in detail in the examples in this chapter and throughout the book.

This book focuses on SPDE models with INLA but it does not cover the basics of Bayesian inference or spatial analysis. For this, Bivand, Pebesma, and Gomez-Rubio (2013) give a thorough description of spatial analysis in R. Banerjee, Carlin, and Gelfand (2014) cover Bayesian inference for different types of spatial models in detail. Blangiardo and Cameletti (2015) and Zuur, Ieno, and Saveliev (2017) give an introduction to INLA and discuss spatial and spatio-temporal models. Wang, Faraway, and Yue Ryan (2018) and Gómez-Rubio (2019) provide a good introduction to INLA and modeling with the INLA package, which are a good resource to learn about INLA.

There are some other resources available on-line or in the INLA package. Lindgren and Rue (2015) is an excellent tutorial available at If you are in a rush to fit a simple geostatistical model, please see the vignette available in the INLA package which can be loaded by typing vignette(SPDEhowto) or a one dimensional example by typing vignette(SPDE1d). A mesh building demonstration Shiny app can be opened by typing meshbuilder().

Finally, a Gitbook version of this book is available from the book website at Here, R code and datasets used in the examples and figures of this book are also available. We have tried to use color-blind friendly palettes throughout the book using packages RColorBrewer and viridisLite, but this can be easily changed in the provided R code.


We would like to thank Sarah Gallup and Helen Sofaer for some English review in the tutorial that originated this book. Our thanks to several people who brought nice problems and questions to the INLA discussion forum at and directly to us. Finally, we are grateful to John Kimmel and CRC for being supportive about the publication of this book and for his help throughout the publication process.

Elias T. Krainski was supported by a grant from the Norwegian Research Council, during the years 2013-2016. Virgilio Gómez-Rubio has been partly supported by grant SBPLY/17/180501/000491, awarded by Consejería de Educación, Cultura y Deportes (JCCM, Spain) and FEDER, grant MTM2016-77501-P, awarded by Ministerio de Economía y Competitividad (Spain) and a grant to support research groups from Universidad de Castilla-La Mancha (Spain).

This book has been written using the bookdown package and R markdown. Map data from Albacete copyrighted OpenStreetMap contributors and is available from


Banerjee, S., B. P. Carlin, and A. E. Gelfand. 2014. Hierarchical Modeling and Analysis for Spatial Data. 2nd ed. Boca Raton, FL: Chapman & Hall/CRC.

Bivand, R. S., E. J. Pebesma, and V. Gomez-Rubio. 2013. Applied Spatial Data Analysis with R. 2nd ed. Springer, NY.

Blangiardo, M., and M. Cameletti. 2015. Spatial and SpatioTemporal Bayesian Models with R-INLA. Chichester, UK: John Wiley & Sons, Ltd.

Gómez-Rubio, V. 2019. Bayesian Inference with INLA. Chapman & Hall/CRC.

Lindgren, F., and H. Rue. 2015. “Bayesian Spatial and Spatio-Temporal Modelling with R-INLA.” Journal of Statistical Software 63 (19).

Lindgren, F., H. Rue, and J. Lindström. 2011. “An Explicit Link Between Gaussian Fields and Gaussian Markov Random Fields: The Stochastic Partial Differential Equation Approach (with Discussion).” J. R. Statist. Soc. B 73 (4): 423–98.

Rue, H., S. Martino, and N. Chopin. 2009. “Approximate Bayesian Inference for Latent Gaussian Models Using Integrated Nested Laplace Approximations (with Discussion).” Journal of the Royal Statistical Society: Series B 71 (2): 319–92.

Wang, X., J. J. Faraway, and Y. Yue Ryan. 2018. Bayesian Regression Modeling with INLA. Boca Raton, FL: Chapman & Hall/CRC.

Zuur, A. F., E. N. Ieno, and A. A. Saveliev. 2017. Beginner’s Guide to Spatial, Temporal and Spatial-Temporal Ecological Data Analysis with R-INLA. Highland Statistics Ltd.