bayespecon.diagnostics.bayesian_lmtests.bayesian_robust_lm_wx_test

bayespecon.diagnostics.bayesian_lmtests.bayesian_robust_lm_wx_test(model)[source]

Bayesian robust LM-WX test (H₀: γ = 0, robust to ρ).

Tests the null hypothesis that the WX coefficients are zero, robust to the local presence of a spatial lag (ρ). Uses the Neyman orthogonal score adjustment from Doğan et al. [2021], Proposition 3, which is the Bayesian analogue of the robust LM-WX test in Koley and Bera [2024].

The alternative model is SAR (includes ρ but not γ). For each posterior draw from the SAR model, residuals are:

\[\mathbf{e} = \mathbf{y} - \rho W \mathbf{y} - X\beta\]

The unadjusted scores are:

\[\begin{split}g_\rho &= \mathbf{e}^\top W \mathbf{y} \\ \boldsymbol{g}_\gamma &= (WX)^\top \mathbf{e}\end{split}\]

The Neyman-adjusted score for γ is:

\[\boldsymbol{g}_\gamma^* = \boldsymbol{g}_\gamma - J_{\gamma\rho \cdot \sigma} J_{\rho\rho \cdot \sigma}^{-1} g_\rho\]

The adjusted weight matrix is:

\[C_{\gamma\gamma}^* = P_{\gamma\gamma} J_{\gamma \cdot \rho}\]

where \(P_{\gamma\gamma} = I - J_{\gamma\rho \cdot \sigma} J_{\rho\rho \cdot \sigma}^{-1} J_{\rho\gamma \cdot \sigma} J_{\gamma \cdot \rho}^{-1}\) and \(J_{\gamma \cdot \rho} = J_{\gamma\gamma \cdot \sigma} - J_{\gamma\rho \cdot \sigma} J_{\rho\rho \cdot \sigma}^{-1} J_{\rho\gamma \cdot \sigma}\).

The robust LM statistic for each draw is:

\[\mathrm{LM}_R = (\boldsymbol{g}_\gamma^*)^\top (C_{\gamma\gamma}^*)^{-1} \boldsymbol{g}_\gamma^*\]

which is distributed as \(\chi^2_{k_{wx}}\) under H₀.

Parameters:
model : SAR

Fitted SAR model instance with inference_data attribute containing posterior draws for beta, rho, and sigma.

Returns:

Dataclass containing LM samples, summary statistics, and metadata. The df field is set to \(k_{wx}\).

Return type:

BayesianLMTestResult