bayespecon.diagnostics.lmtests.bayesian_lm_lag_sdem_test

bayespecon.diagnostics.lmtests.bayesian_lm_lag_sdem_test(model)[source]

Bayesian LM-Lag test from an SDEM posterior (H₀: ρ = 0 | SDEM).

Tests whether an SDEM model should be extended to MANSAR by adding a spatial lag of y. Residuals are the spatially filtered SDEM residuals:

\[\mathbf{u} = (I - \lambda W) \bigl(\mathbf{y} - X\beta - WX\theta\bigr)\]

The score and variance follow the SDEM-filtered LM-Lag derivation: using the whitened lag vector \(\tilde z_\rho = \bar A_\lambda W\mathbf{y}\) with \(\bar A_\lambda = I - \bar\lambda W\) and the whitened design \(\tilde Z = \bar A_\lambda [X, WX]\),

\[S = \mathbf{u}^\top \tilde z_\rho, \qquad V = \bar\sigma^4 \, T_{WW} + \bar\sigma^2 \, \tilde z_\rho^{\top} M_{\tilde Z}\, \tilde z_\rho.\]

Note

In the SDEM filter context this naive test coincides algebraically with bayesian_robust_lm_lag_sdem_test(): the \(\gamma\)-score vanishes by the SDEM normal equations and the filter absorbs \(\lambda\) at \(\bar\lambda\), so the Doǧan Neyman-orthogonal Schur adjustment for \((\gamma,\lambda)\) is a no-op. Earlier revisions used an unwhitened \(S = \boldsymbol{\varepsilon}^\top W\mathbf{y}\) paired with \(V = \bar\sigma^4 T_{WW} + \bar\sigma^2 \|W \mathbf{y}\|^2\), which produced empirical size near 1 on SDEM-DGP because both the numerator and the denominator omitted the \(\bar A_\lambda\) whitening factor.

Returns LM = S^2 / V per draw, distributed as \(\chi^2_1\) under H₀.