bayespecon.diagnostics.lmtests.bayesian_lm_wx_sem_test¶
- bayespecon.diagnostics.lmtests.bayesian_lm_wx_sem_test(model)[source]¶
Bayesian LM test for WX coefficients in SEM (H₀: γ = 0 | SEM).
Tests whether spatially lagged covariates (WX) should be added to a SEM model — i.e. whether SEM should be extended to SDEM. Bayesian extension of the classical LM-WX test ([Koley and Bera, 2024]) using the Doğan, Taşpınar & Bera (2021) framework ([Doğan et al., 2021], Proposition 1).
The null model is SEM (includes \(\lambda\) but not \(\gamma\)). For each posterior draw of \((\beta, \lambda, \sigma^2)\) the raw score is
\[\mathbf{g}_\gamma^{(d)} = (WX)^\top \mathbf{e}^{(d)}, \qquad \mathbf{e}^{(d)} = \mathbf{y} - X \beta^{(d)}.\]Under \(H_0\) the variance of the raw score is the same Schur- complemented quantity used by spreg’s
lm_wx([Koley and Bera, 2024]):\[V_{\gamma\gamma} = \bar{\sigma}^2 \, (WX)^\top M_X (WX),\]where \(M_X = I - X(X^\top X)^{-1} X^\top\) and \(\bar{\sigma}^2\) is the posterior mean of \(\sigma^2\). The per-draw LM statistic is
\[\mathrm{LM}^{(d)} = \mathbf{g}_\gamma^{(d)\,\top} V_{\gamma\gamma}^{-1} \mathbf{g}_\gamma^{(d)} \;\xrightarrow{d}\; \chi^2_{k_{wx}} \quad \text{under } H_0.\]