bayespecon.diagnostics.lmtests.bayesian_panel_robust_lm_lag_test

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

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

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

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{y}}{\sigma^2} - \frac{\mathbf{e}^\top W_{NT} \mathbf{e}}{\sigma^2} \right)^2 }{J - T \cdot \mathrm{tr}(W'W + W^2)}\]

where \(J\) is the information matrix from the panel LM-lag test and \(\mathrm{tr}\) denotes \(\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_lag_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