The Latent Field
Understanding how fixed effects, random effects, and the linear predictor η combine to form the latent Gaussian structure at the heart of INLA.
What is the Latent Field?
The latent field x is the collection of all unobserved Gaussian random variables in an INLA model. It includes:
- Intercept α: the global baseline
- Fixed effect coefficients β: regression parameters for covariates
- Random effect values f(k): structured or unstructured latent components (IID, temporal, spatial, ...)
Together, these form a high-dimensional Gaussian Markov Random Field (GMRF) that INLA approximates efficiently. The linear predictor η is then computed from x via a single sparse multiplication η = Apred x (defined in Model Representation below).
Three-Level Hierarchy
INLA models have a natural three-level hierarchical structure:
Hyperparameter Model
Priors on hyperparameters (precisions, correlations, etc.)
Latent Field Model
The latent field as a GMRF with sparse precision matrix Q
Observation Model
Likelihood connecting the linear predictor to observations
The Linear Predictor
The linear predictor ηi combines all model components for observation i:
Connecting η to the Response
A link function g connects the linear predictor to the expected response:
gaussian
identity
poisson
log
binomial
logit
gamma
log
beta
logit
Model Representation
INLA uses a compact representation where the linear predictor is computed via a single sparse matrix multiplication that combines every component of the latent field:
Each block A(k) is the projector for one component of the latent field. The global Apred stacks them side by side, so fixed effects, IID effects, and an SPDE term can all contribute to the same row of η.
A often refers specifically to the mesh-to-observation projector for that one term. On this page, Apred is the global predictor matrix that bundles every component, including the SPDE block, into one row-stacked operator.
Per-component blocks A(k)
Each block extracts the contribution of one latent component to each observation. Typical shapes:
- Fixed effects: A(β) is the design matrix of covariate values (one row per observation, one column per coefficient).
- IID / temporal / areal: a selection matrix that picks the group, time index, or region for each observation.
- SPDE: a barycentric projector that interpolates the mesh-node field at each observation location.
The Latent Field x
The vector x stacks all latent Gaussian variables in the same order as the blocks of Apred:
- Intercept and fixed-effect coefficients β
- Random effect vectors f(1), ..., f(K)
- Dimension can far exceed n (e.g., SPDE mesh nodes, large group counts)
Building a Complete Model
Here's how the components combine in a typical model:
# Model: y ~ 1 + x1 + x2 + f(group)
# η_i = α + β₁·x1_i + β₂·x2_i + f_group[i]
formula = {
'response': 'y',
'fixed': ['1', 'x1', 'x2'], # Intercept + 2 covariates
'random': [
{'id': 'group', 'model': 'iid'} # Random intercepts
]
}
result = pyinla(
formula=formula,
family='gaussian',
data=df
)
# The latent field x contains:
# - α (intercept)
# - β₁ (coefficient for x1)
# - β₂ (coefficient for x2)
# - f_1, f_2, ..., f_G (G group effects)
Latent Model Components
PyINLA documents the latent model components below, grouped by what kind of dependence structure they impose. Each tile links to a dedicated article with the spec surface, math, runnable code snippets, and parity status. New models are added as their per-model schema and parity sweep land.
Exchangeable / IID
Temporal Models
RW1
First-order random walk. Adjacent values similar, captures local trends.
RW2
Second-order random walk. Smoother trends, penalizes curvature.
AR1
First-order autoregression. Exponentially decaying correlation.
AR(p)
Higher-order autoregression with p lag terms.
Seasonal
Periodic effects for seasonal patterns in time series.
Spatial Models (Areal Data)
Spatial Models (Continuous / SPDE)
Generic / User-Defined Models
Conditional Independence
A key assumption in INLA is that observations are conditionally independent given the latent field:
This means all dependence between observations is captured through the latent field structure. The precision matrix Q encodes the conditional independence structure of the latent field itself, making computations efficient via sparse matrix methods.
Key Takeaways
- The latent field x stacks the intercept, fixed-effect coefficients, and every random-effect vector into one Gaussian GMRF.
- The linear predictor η is recovered from x via the block-stacked operator η = Apred x, then connected to the response by the link function g(𝔼[y]) = η.
- INLA exploits the sparse precision matrix Q of x for efficient computation; nothing dense ever needs to be inverted.
- Pick a random-effect model that matches the dependence structure in your data: exchangeable (IID), temporal (RW, AR, seasonal), areal (Besag, BYM2), or continuous-spatial (SPDE).