bayespecon.diagnostics.lmtests.bayesian_robust_lm_lag_sem_test¶
- bayespecon.diagnostics.lmtests.bayesian_robust_lm_lag_sem_test(model)[source]¶
Bayesian robust LM-Lag test in SEM context (H₀: ρ = 0 | SEM).
Tests whether a SEM fit should be extended to add a spatial lag (→ SARAR or SDM/SDEM family), robust to the WX block. The SEM posterior provides \((\beta, \lambda, \sigma^2)\); treating \(\bar\lambda\) as the filtering point, the alternative model becomes a filtered OLS with two candidate omitted blocks (\(\rho\) for the lag, \(\gamma\) for WX).
For each posterior draw the whitened residual is \(\mathbf{u}^{(d)} = (I - \lambda^{(d)} W) (\mathbf{y} - X\beta^{(d)})\). In the filter at \(\bar\lambda\) let \(\tilde z_\rho = \bar A_\lambda W\mathbf{y}\) and \(\tilde Z_\gamma = \bar A_\lambda WX\). Raw scores are
\[g_\rho^{(d)} = \mathbf{u}^{(d)\,\top} \tilde z_\rho, \qquad \mathbf{g}_\gamma^{(d)} = \tilde Z_\gamma^{\top} \mathbf{u}^{(d)}.\]Variance blocks come from
_sem_filtered_blocks(). The Neyman-orthogonal score adjusts \(g_\rho\) for the \(\gamma\) direction:\[\begin{split}g_\rho^{*\,(d)} &= g_\rho^{(d)} - V_{\rho\gamma} V_{\gamma\gamma}^{-1} \mathbf{g}_\gamma^{(d)},\\ V_{\rho\,|\,\gamma} &= V_{\rho\rho} - V_{\rho\gamma} V_{\gamma\gamma}^{-1} V_{\gamma\rho}.\end{split}\]The per-draw statistic is
\[\mathrm{LM}_R^{(d)} = \frac{(g_\rho^{*\,(d)})^2} {V_{\rho\,|\,\gamma}} \;\xrightarrow{d}\; \chi^2_1 \quad \text{under } H_0,\]independent of local misspecification in \(\gamma\).