bayespecon.diagnostics.bayesian_lmtests.bayesian_panel_lm_lag_test¶
- bayespecon.diagnostics.bayesian_lmtests.bayesian_panel_lm_lag_test(model)[source]¶
Bayesian panel LM test for omitted spatial lag (H₀: ρ = 0).
Follows Anselin et al. [2008] and the Bayesian framework of Doğan et al. [2021]. (2021). Tests whether a spatial lag term should be added to a panel regression.
The null model is a pooled/FE panel OLS. For each posterior draw, residuals are:
\[\mathbf{e} = \mathbf{y} - X \beta\](demeaned for FE models; with alpha subtracted for RE models).
The score for each draw is:
\[S = \mathbf{e}^\top W_{NT} \mathbf{y}\]where \(W_{NT} = W \otimes I_T\) is the block-diagonal panel weights matrix.
The information matrix (Anselin et al. [2008]) is:
\[J = \frac{1}{\sigma^2} \left( (W\hat{y})^\top M (W\hat{y}) + T \cdot \mathrm{tr}(W'W + W^2) \right)\]where \(M = I - X(X^\top X)^{-1} X^\top\) and \(\hat{y} = X\bar{\beta}\).
The LM statistic for each draw is:
\[\mathrm{LM} = \frac{S^2}{\sigma^2 \cdot J}\]which is distributed as \(\chi^2_1\) under H₀.
- Parameters:¶
- model : SpatialPanelModel¶
Fitted panel model (e.g.
OLSPanelFE,OLSPanelRE) withinference_dataattribute containing posterior draws forbetaandsigma.
- Returns:¶
Dataclass containing LM samples, summary statistics, and metadata.
- Return type:¶