bayespecon.diagnostics.lmtests.bayesian_panel_robust_lm_error_test

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

Bayesian panel robust LM-Error test (H₀: λ = 0, robust to ρ).

Follows Elhorst [2014]. Tests the null hypothesis that the spatial error coefficient is zero, robust to the local presence of a spatial lag.

The null model is a pooled/FE panel OLS. For each posterior draw,

\[\mathrm{LM}_R = \frac{ \left( \frac{\mathbf{e}^\top W_{NT} \mathbf{e}}{\sigma^2} - \frac{T \cdot \mathrm{tr}}{J} \cdot \frac{\mathbf{e}^\top W_{NT} \mathbf{y}}{\sigma^2} \right)^2 }{ T \cdot \mathrm{tr} \cdot \left(1 - \frac{T \cdot \mathrm{tr}}{J}\right) }\]

where \(J\) is the information matrix from the panel LM-lag test and \(\mathrm{tr} = \mathrm{tr}(W'W + W^2)\).

The score is evaluated at the M_X-projected residual \(\mathbf{e}_\perp = M_X \mathbf{y}\) (constant across draws), because \(\beta\) is information-orthogonal to \((\rho,\lambda)\) under \(H_0\) and therefore \(\beta\)-posterior variance does not enter the LM reference distribution. This matches the cross-sectional correction documented in bayesian_robust_lm_error_test().

This is distributed as \(\chi^2_1\) under H₀.

Parameters:
model : SpatialPanelModel

Fitted panel model (e.g. OLSPanelFE) with inference_data attribute containing posterior draws for beta and sigma.

Returns:

Dataclass containing LM samples, summary statistics, and metadata.

Return type:

BayesianLMTestResult