Approximate Bayesian inference for structural equation models

CFE-CMStatistics 2026 · CO161 Advances in Bayesian computational methods

Haziq Jamil

Research Specialist
BAYESCOMP @ CEMSE-KAUST

https://haziqj.ml/cmstat26 | 📥 PDF

Håvard Rue

Professor of Statistics
BAYESCOMP @ CEMSE-KAUST

December 12, 2026

\[ \definecolor{kaustorg}{RGB}{241, 143, 0} \definecolor{kausttur}{RGB}{0, 166, 170} \definecolor{kaustmer}{RGB}{177, 15, 46} \definecolor{kaustgrn}{RGB}{173, 191, 4} \definecolor{kaustblu}{RGB}{82, 132, 196} \definecolor{kaustpur}{RGB}{156, 111, 174} \]

Bayesian Computational Statistics and Modeling Research Group (BAYESCOMP)

Led by Prof. Håvard Rue—Integrated Nested Laplace Approximation (INLA, Rue et al., 2009)

Problem statement

  • SEM: regressions among latent variables, each measured by several noisy indicators.

  • In practice, Bayesian SEM needs many fits: model building, prior sensitivity, cross-validation, simulations.

  • MCMC per fit is the bottleneck.

  • INLA (Rue et al., 2009)…

    • works on latent Gaussian models.
    • is fast, deterministic and accurate.
    • is used in various other fields such as spatial statistics and biostatistics.

This talk

A ✨bespoke✨ ground-up implementation of INLA for normal-theory SEM (continuous indicators).

This work is supported by the 2025 KAUST Competitive Research Grant (CRG) Award No. URF/1/6921-01-01.

SEM as a latent Gaussian model

Bayesian Political Democracy example (Bollen, 1989)

  • Does industrialisation drive democracy? \(p=11\) indicators on \(n=75\) countries measure \(q=3\) factors: industrialisation (1960) and democracy (1960, 1965).

  • For \(s=1,\dots,n\), independently,

    \[ \begin{aligned} \mathbf y_s \mid \boldsymbol\eta_s, \boldsymbol\vartheta &\sim \operatorname{N}_p\big(\boldsymbol\nu + {\color{kaustpur}\boldsymbol\Lambda}\boldsymbol\eta_s,\ {\color{kaustorg}\boldsymbol\Theta}\big) \\ \boldsymbol\eta_s \mid \boldsymbol\vartheta &\sim \operatorname{N}_q\big((\mathbf I - {\color{kaustgrn}\mathbf B})^{-1}\boldsymbol\alpha,\ \boldsymbol\Phi\big) \\ \boldsymbol\vartheta &\sim \pi(\boldsymbol\vartheta) \end{aligned} \]

    with \(\boldsymbol\Phi = (\mathbf I - {\color{kaustgrn}\mathbf B})^{-1}{\color{kausttur}\boldsymbol\Psi}(\mathbf I - {\color{kaustgrn}\mathbf B})^{-\top}\).

  • \(\boldsymbol\vartheta\in\mathbb R^m\) collects all free entries (\(m = 42\)). Priors are blavaan’s non-informative defaults.

Bayesian inference

\[ \pi(\boldsymbol\vartheta \mid \mathbf y) \propto \pi(\boldsymbol\vartheta) \prod_{s=1}^n \left\{ \int \pi(\mathbf y_s \mid \boldsymbol\eta_s, \boldsymbol\vartheta)\, \pi(\boldsymbol\eta_s \mid \boldsymbol\vartheta)\, d\boldsymbol\eta_s \right\} \]

Conditional likelihood (keep \(\boldsymbol\eta\))

  • MCMC + data augmentation
  • INLA proper (\(\boldsymbol\eta\) as latent field)
    • Tiny independent blocks; little for sparse linear algebra to gain.
    • Many parameter evaluations, each factorising over all \(n\).
    • R-INLA: 6 s (\(n=75\)), 125 s (\(n=7500\)).

Marginal likelihood (integrate \(\boldsymbol\eta\))

  • Closed form \(\mathbf y_s \mid \boldsymbol\vartheta \sim \operatorname{N}_p(\boldsymbol\mu, \boldsymbol\Sigma)\), where \[ \begin{aligned} \boldsymbol\mu(\boldsymbol\vartheta) &= \boldsymbol\nu + \boldsymbol\Lambda(\mathbf I - \mathbf B)^{-1}\boldsymbol\alpha \\ \boldsymbol\Sigma(\boldsymbol\vartheta) &= \boldsymbol\Lambda\boldsymbol\Phi\boldsymbol\Lambda^\top + \boldsymbol\Theta \end{aligned} \]
    • Cost free of \(n\); sufficient statistics \((\bar{\mathbf y}, \mathbf S)\).
    • Factor scores \(\boldsymbol\eta_s \mid \mathbf y_s, \boldsymbol\vartheta \sim \operatorname{N}_q(\mathbf m_s, \mathbf V)\) are Gaussian too.
    • Stan implementation outperforms JAGS (Merkle et al., 2021).
  • INLA without \(\boldsymbol\eta\): working space is \(\mathbb R^m\).

INLA-based posterior approximation

Overview

  • A ✨bespoke✨ INLA for SEM, making use of relevant key ideas (Laplace, simplified-Laplace marginals, a VB correction).

  • Steps 1 and 2 use the exact unnormalised log-posterior and its analytic gradient (Neudecker & Satorra, 1991; von Oertzen & Brick, 2014).

[Step 1] Laplace and the VB mean shift

  • From a 2nd order Taylor expansion about \(\boldsymbol\vartheta^* = \operatorname*{argmax}_{\boldsymbol\vartheta} \log \pi(\boldsymbol\vartheta \mid \mathbf y)\), \[ \log \pi(\boldsymbol\vartheta \mid \mathbf y) = \log \pi(\boldsymbol\vartheta^* \mid \mathbf y) - \frac12 (\boldsymbol\vartheta - \boldsymbol\vartheta^*)^\top \boldsymbol\Omega^{-1} (\boldsymbol\vartheta - \boldsymbol\vartheta^*) + O\big(\lVert\boldsymbol\vartheta - \boldsymbol\vartheta^*\rVert^3\big), \] able to approximate the posterior by \(\operatorname{N}_m(\boldsymbol\vartheta^*, \boldsymbol\Omega)\), where \(\boldsymbol\Omega^{-1} = \mathbf H := -\nabla^2 \log \pi(\boldsymbol\vartheta \mid \mathbf y) \big|_{\boldsymbol\vartheta=\boldsymbol\vartheta^*}\).
  • Correct the mean of the Laplace using variational Bayes principles (Zellner, 1988): \[ \hat{\boldsymbol\delta} = \operatorname*{argmin}_{\boldsymbol\delta} \operatorname{D}_{\text{KL}}\big( \mathcal{N}_m(\cdot \,;\, \boldsymbol\vartheta^* + \boldsymbol\delta, \boldsymbol\Omega) \;\Vert\; \pi(\cdot \mid \mathbf y) \big). \]

  • Laplace gets the shape (curvature) right, but often the location wrong. Avoid the massive cost of (re-)optimising \(\boldsymbol\Omega\) (van Niekerk & Rue, 2024).
  • Work on an unconstrained parameterisation (\(\log\) variances, \(\operatorname{atanh}\) correlations) to ensure the log-posterior is closer to quadratic.

[Step 2] Posterior marginals

  • Laplace again, now on the marginalisation integral of the exact posterior:

\[ \class{marginal-lhs}{\pi(\vartheta_j \mid \mathbf y)} = \int_{\mathbb R^{m-1}} e^{\log \pi(\vartheta_j, \boldsymbol\vartheta_{-j} \mid \mathbf y)} \, \mathrm d \boldsymbol\vartheta_{-j} \, \approx \, \overbrace{\pi\big(\vartheta_j, \boldsymbol\vartheta_{-j}^*(\vartheta_j) \mid \mathbf y\big)}^{\textstyle\text{height}} \times \overbrace{(2\pi)^{\frac{m-1}{2}} \left| \mathbf H_{-j}(\vartheta_j) \right|^{-1/2 }}^{\textstyle\text{(cond.) width}} \]

  • Geometric intuition: the marginal at each \(\vartheta_j\) is the volume of the posterior’s slice there, roughly the slice’s peak height times its width.
  • This is expensive to compute, as for every \(\vartheta_j\) evaluation, need

    1. An optimisation of \(\boldsymbol\vartheta_{-j}\in\mathbb R^{m-1}\) at this location; and
    2. The (log-) determinant of the Hessian there.
  • Next slides: two important results.

[Step 2a] Posterior marginals—the “height”

Lemma 1 (Conditional mean path) = No re-optimisation

Let \(\small \boldsymbol\vartheta\sim\operatorname{N}_m(\boldsymbol\vartheta^*,\boldsymbol\Omega)\) with \(\small\boldsymbol\Omega \succ \mathbf 0\). Then the marginal density of the \(\small j\)th component, \(\small j=1,\dots,m\), is proportional to the joint density evaluated along its CMP: \[ \small \pi(\vartheta_j=x) \propto \pi\big(\vartheta_j=x, \, \boldsymbol\vartheta_{-j} = \operatorname{E}[ \boldsymbol\vartheta_{-j} \mid \vartheta_j=x] \big). \]

  • Operationally,

    1. Lay out a grid \(\mathcal G_j=\big\{\boldsymbol\vartheta^* + t\,\mathbf v_j \;\big|\;t\in[-4,4]\big\}\), \(\mathbf v_j = \boldsymbol\Omega_{\cdot j} / \Omega_{jj}^{1/2}\).
    2. Evaluate joint posterior \(\pi(\boldsymbol\vartheta \mid \mathbf y)\) at each grid point.
  • Scanning along the CMP is cheap; no re-optimisation needed.

  • For Gaussian posteriors, this is exact; otherwise it provides a first-order approximation to a potentially curved ridge.

[Step 2b] Posterior marginals—the “width”

Lemma 2 (Efficient volume correction) = No need to factor dense Hessian

For the \(\small j\)th component along the CMP, \(\small-\frac12 \log | \mathbf H_{-j}(t) | \approx \text{const.} + t\gamma_j'\). Then \[ \small \gamma_j' = -\frac{1}{2} \sum_{k=1}^m \frac{d}{dt} \left[ \mathbf{L}_{\cdot k}^{\top}\,\frac{d}{d\mathbf{L}_{\cdot k}}\mathbf{g} \right]_{t=0} + \frac{1}{2}\, \frac{d}{dt} \left[ \mathbf{v}_j^{\top}\,\frac{d}{d\mathbf{v}_j}\mathbf{g} \right]_{t=0}, \] where \(\small\mathbf{g}(\boldsymbol\vartheta) = -\nabla \log \pi(\boldsymbol\vartheta \mid \mathbf{y})\), and \(\small\mathbf H(\boldsymbol\vartheta^*)^{-1}=\mathbf L\mathbf L^\top\).

  • For non-symmetric densities, the conditional spread (“width”) changes along the scan line. This change can be computed entirely via directional derivatives.

  • Forward difference cost is only \(m+2\) gradient evaluations for each \(j\). Note: Baseline is unity in whitened coordinates.

    1. [outer \(\small\nabla^3\)] Shift to \(\boldsymbol\vartheta^+\) along CMP, evaluate gradient.
    2. [inner \(\small\nabla^2\)] Perturb along \(\mathbf{L}_{\cdot k}\) and the scan direction \(\mathbf{v}_j\), evaluating gradients.

[Step 2c] Posterior marginals—SN curve fit

  • Consider the paired points \(\{\vartheta_j(t_k), h_{kj}\}_{k=1}^K\), where
    • \(t_k\in[-4,4]\) are standardised grid points,
    • \(\boldsymbol\vartheta(t_k) = \boldsymbol\vartheta^* + t_k \mathbf v_j\) from the CMP, and
    • \(h_{kj} := h_j(t_k) = \log \pi(\boldsymbol\vartheta(t_k) \mid \mathbf y ) + t_k \gamma_j'\) are unnormalised ordinates.
  • Fit a skew normal pdf to these points via weighted least squares. A convenient default is \(w_{kj} \propto \exp(h_{kj})\), for \(j=1,\dots m\).

  • Map back from \(t\) to \(\vartheta_j\) scale via the affine \(\vartheta_j = \vartheta_j^* + t\sqrt{\Omega_{jj}}\).

\[(\hat\xi_j,\hat\omega_j,\hat\alpha_j,\hat c_j) = \operatorname{argmin}_{\xi,\omega,\alpha,c} \, \sum_{k=1}^K w_{kj}\big[ h_{kj}-\big\{\log f_{\mathrm{SN}}(\vartheta_j(t_k);\xi,\omega,\alpha)+c\big\} \big]^2\]

[Step 3] Gaussian copula sampling

\[ \underbrace{\mathbf z \sim N_m(\mathbf 0, \mathbf R)}_{\text{Gaussian correlation}} \xrightarrow{\quad \Phi(\cdot) \quad} \underbrace{\mathbf u}_{\ \text{Uniform} \ } \xrightarrow{\quad F_{\text{SN}}^{-1}(\cdot) \quad} \underbrace{\boldsymbol\vartheta}_{\text{SN Marginals}} \]

  • Reconstruct joint posterior samples \(\{\boldsymbol\vartheta^{(1)},\dots,\boldsymbol\vartheta^{(B)}\}\) using a Copula (Nelsen, 2006), preserving Gaussian correlations: \[ \mathbf R = \mathbf D^{-1/2} \boldsymbol \Omega \mathbf D^{-1/2}, \qquad \mathbf D = \operatorname{diag}(\boldsymbol\Omega). \]

  • This also allows us to derive approximate posteriors for

    1. Parameter transformations, e.g. standardised solutions, non-linear transforms, etc.
    2. Posterior Predictive P-value (PPP), e.g. \(\#\{ T(\mathbf S_{\text{obs}}, \boldsymbol\Sigma(\boldsymbol\vartheta)) > T(\mathbf S_{\text{rep}}, \boldsymbol\Sigma(\boldsymbol\vartheta)) \}\).
    3. Factor scores, \(\boldsymbol\eta \mid \{\mathbf y_s, \boldsymbol\vartheta\} \sim \operatorname{N}_q(\mathbf m_s(\boldsymbol\vartheta), \mathbf V(\boldsymbol\vartheta))\).
    4. Prediction and imputation.

Software and validation

R/INLAvaan

library(INLAvaan)
mod <- "
  ind60 =~ x1 + x2 + x3
  dem60 =~ y1 + y2 + y3 + y4
  dem65 =~ y5 + y6 + y7 + y8

  dem60 ~ ind60
  dem65 ~ ind60 + dem60

  y1 ~~ y5
  y2 ~~ y4 + y6
  y3 ~~ y7
  y4 ~~ y8
  y6 ~~ y8

  ind60 ~~ prior('gamma(1, 1)')*ind60
  dem60 ~~ prior('gamma(2, 1)')*dem60
  dem65 ~~ prior('gamma(1,.5)')*dem65
"

  • (b)lavaan syntax and methods.
  • asem(), acfa(), agrowth() with dp = priors_for() option.
  • Written in pure R; no INLA dependence/compiled code (yet).

Comparison with MCMC

What each layer buys

N
JS discrepancy (%)
ΔMean (posterior SDs)
(i) Laplace (ii) + VB (iii) SN (i) (ii) (iii)
Intercepts 11 0.05 0.05 0.05 0.011 0.011 0.011
Loadings 8 2.40 0.89 0.24 0.311 0.086 0.053
Regressions 3 0.54 0.28 0.17 0.127 0.012 0.023
Resid. variances 11 2.42 0.64 0.24 0.317 0.058 0.044
Resid. correlations 6 0.28 0.11 0.10 0.096 0.027 0.022
Latent variances 3 2.25 1.64 0.56 0.278 0.037 0.082
Overall 42 1.34 0.50 0.19 0.188 0.042 0.035
  • Error against the long MCMC run on the benchmark, by parameter class. Same mode and Hessian throughout.
  • (i)\(\to\)(ii): the mode-to-mean gap is the dominant error at \(n=75\) (JS discrepancy 1.34% to 0.50%). (ii) and (iii) then have similar mean error (0.042 vs 0.035 SD), as theory predicts (Jamil & Rue, 2026, Prop. 3.4).
  • (ii)\(\to\)(iii): the skew-normal shape cuts the JS discrepancy to 0.19%, a seventh of Laplace’s, for about 1 s more.
  • Without \(\gamma_j'\) it is 0.91%, worse than (ii). The gradient-only \(\gamma_j'\) matches a full numerical Hessian (0.19%, 0.035) and is 0.8 s faster.

Stress test on simulated data

  • Five one-at-a-time perturbations of the benchmark: 18 conditions \(\times\) 100 replications, each paired with HMC.
  • Benign (\(n\) from 40 to 1200, a variance near zero, \(m\) up to 156): median worst-case error at most 0.32 posterior SDs, and 95% coverage within 3 points of nominal.
  • Weak identification breaks it: 1.63 SD at standardised loadings of 0.3. But 64 of 100 HMC references fail there too.
  • Cost grows slowly with \(m\): 1.5, 5.6 and 9 s at \(m = 42\), 80 and 156, against 15 s, 1 min and 8 min per MCMC chain.

Conclusion

Summary and outlook

  • 🚀 INLA methodology offers a rapid alternative for SEM, delivering accurate Bayesian results at near-frequentist speed.
    • A companion to MCMC, not a replacement: for model building, prior sensitivity, CV…

Limitations

  • Needs one dominant interior mode; weak identification can break \(\mathbf H \succ 0\) (but HMC struggles there too).

  • Near-zero variances push the SN fit to its limits: lower tail understated, so check against MCMC.

  • The Gaussian copula captures pairwise correlations, but not extreme tail dependence.

  • Cost grows with \(m\); tested to \(m = 256\) in about 20 s.

Where next

Vielen Dank

https://haziqj.ml/cmstat26 | backup slides

  • Jamil, H., & Rue, H. (2026a). Approximate Bayesian inference for structural equation models using integrated nested Laplace approximations (arXiv:2603.25690).
  • Jamil, H., & Rue, H. (2026b). Implementation and workflows for INLA-based approximate Bayesian structural equation modelling (arXiv:2604.00671).
  • Alhyari, M., Jamil, H., Montcho, H., & Rue, H. (2026). Deterministic leave-one-cluster-out cross-validation for multilevel Bayesian structural equation models (arXiv:2609.00670).
  • R package: install.packages("INLAvaan"), docs at https://inlavaan.haziqj.ml.

References

Andersson, B., & Xin, T. (2021). Estimation of Latent Regression Item Response Theory Models Using a Second-Order Laplace Approximation. Journal of Educational and Behavioral Statistics, 46(2), 244–265. https://doi.org/10.3102/1076998620945199
Bollen, K. A. (1989). Structural equations with latent variables. Wiley. https://doi.org/10.1002/9781118619179
Driver, C. C., Oud, J. H. L., & Voelkle, M. C. (2017). Continuous Time Structural Equation Modeling with R Package ctsem. Journal of Statistical Software, 77(5). https://doi.org/10.18637/jss.v077.i05
Freni-Sterrantino, A., van Niekerk, J., Krainski, E., Rustand, D., Jamil, H., & Rue, H. (2026). Informative distance-based priors for correlation matrices centred on a target reference. https://doi.org/10.48550/arXiv.2607.18926
Hecht, M., Hardt, K., Driver, C. C., & Voelkle, M. C. (2019). Bayesian continuous-time Rasch models. Psychological Methods, 24(4), 516–537. https://doi.org/10.1037/met0000205
Jamil, H., & Rue, H. (2026). Approximate Bayesian inference for structural equation models using integrated nested Laplace approximations (2603.25690 [stat.ME]). arXiv. https://doi.org/10.48550/arXiv.2603.25690 (Pre-published)
Krainski, E., Gómez-Rubio, V., Bakka, H., Lenzi, A., Castro-Camilo, D., Simpson, D. P., Lindgren, F., & Rue, H. (2018). Advanced spatial modeling with stochastic partial differential equations using R and INLA. Chapman and Hall/CRC. https://doi.org/10.1201/9780429031892
Lüdtke, O., Robitzsch, A., & Wagner, J. (2018). More stable estimation of the STARTS model: A Bayesian approach using Markov chain Monte Carlo techniques. Psychological Methods, 23(3), 570–593. https://doi.org/10.1037/met0000155
Merkle, E. C., Fitzsimmons, E., Uanhoro, J., & Goodrich, B. (2021). Efficient Bayesian structural equation modeling in Stan. Journal of Statistical Software, 100(6), 1–22. https://doi.org/10.18637/jss.v100.i06
Nelsen, R. B. (2006). An introduction to copulas (2nd ed.). Springer.
Neudecker, H., & Satorra, A. (1991). Linear structural relations: Gradient and Hessian of the fitting function. Statistics & Probability Letters, 11(1), 57–61. https://doi.org/10.1016/0167-7152(91)90178-T
Rue, H., Martino, S., & Chopin, N. (2009). Approximate Bayesian inference for latent Gaussian models by using integrated nested Laplace approximations. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 71(2), 319–392. https://doi.org/10.1111/j.1467-9868.2008.00700.x
Simpson, D. P., Rue, H., Riebler, A., Martins, T. G., & Sørbye, S. H. (2017). Penalising model component complexity: A principled, practical approach to constructing priors. Statistical Science, 32(1), 1–28. https://doi.org/10.1214/16-STS576
Tierney, L., & Kadane, J. B. (1986). Accurate approximations for posterior moments and marginal densities. Journal of the American Statistical Association, 81(393), 82–86. https://doi.org/10.1080/01621459.1986.10478240
van Niekerk, J., & Rue, H. (2024). Low-rank variational Bayes correction to the Laplace method. Journal of Machine Learning Research, 25(62), 1–25. https://jmlr.org/papers/v25/21-1405.html
von Oertzen, T., & Brick, T. R. (2014). Efficient Hessian computation using sparse matrix derivatives in RAM notation. Behavior Research Methods, 46(2), 385–395. https://doi.org/10.3758/s13428-013-0384-4
Zellner, A. (1988). Optimal information processing and Bayes’s theorem. The American Statistician, 42(4), 278–280. https://doi.org/10.2307/2685143