bayespecon.diagnostics.lmtests.bayesian_lm_wx_test

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

Bayesian LM test for WX coefficients (H₀: γ = 0 | SAR).

Tests whether spatially lagged covariates (WX) should be added to a SAR model — i.e. whether SAR should be extended to SDM. Bayesian extension of the classical LM-WX test ([Koley and Bera, 2024], eq. for RS_gamma) using the Doğan, Taşpınar & Bera (2021) framework ([Doğan et al., 2021], Proposition 1).

The null model is SAR (includes \(\rho\) but not \(\gamma\)). For each posterior draw of \((\beta, \rho, \sigma^2)\) the raw score is

\[\mathbf{g}_\gamma^{(d)} = (WX)^\top \mathbf{e}^{(d)}, \qquad \mathbf{e}^{(d)} = \mathbf{y} - \rho^{(d)} W\mathbf{y} - X \beta^{(d)}.\]

Concentrating \(\beta\) out of the SDM information matrix gives the variance of the raw score under \(H_0\):

\[V_{\gamma\gamma} = \bar{\sigma}^2 \, (WX)^\top M_X (WX), \qquad M_X = I - X(X^\top X)^{-1} X^\top.\]

This is the same Schur-complement quantity used by spreg’s lm_wx ([Koley and Bera, 2024]), evaluated at the posterior mean \(\bar{\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.\]
Parameters:
model : SAR

Fitted SAR model with inference_data attribute providing posterior draws of beta, rho, sigma and the cached _y, _X, _WX, _Wy attributes.

Returns:

Per-draw LM samples, summary statistics, and metadata. df = k_{wx} (the number of WX columns).

Return type:

BayesianLMTestResult