bayespecon.diagnostics.lmtests.bayesian_lm_lag_test¶
- bayespecon.diagnostics.lmtests.bayesian_lm_lag_test(model)[source]¶
Bayesian LM test for omitted spatial lag (SAR) model.
Bayesian extension of the classical LM-Lag test ([Anselin et al., 1996], eq. 13) using the Doğan, Taşpınar & Bera (2021) quadratic-net-loss framework ([Doğan et al., 2021], Proposition 1):
Score \(s_\rho(\theta)\) evaluated at every posterior draw of \((\beta, \sigma^2)\) from the OLS null fit.
Concentration matrix \(C_{\rho\rho \cdot \beta}(\theta^\star)\) evaluated at the posterior mean \(\theta^\star\) (Doğan eq. 3.6).
Posterior averaging of the per-draw quadratic form yields the Bayesian LM statistic with asymptotic \(\chi^2_1\) reference.
For each posterior draw the raw score is
\[S^{(d)} = \mathbf{e}^{(d)\,\top} W \mathbf{y}, \qquad \mathbf{e}^{(d)} = \mathbf{y} - X \beta^{(d)}.\]Concentrating \(\beta\) out of the SAR Fisher information ([Anselin et al., 1996], eq. 13) gives the variance of the raw score under \(H_0\):
\[V = \bar{\sigma}^4 \, T_{WW} + \bar{\sigma}^2 \, \| M_X \, W X \bar{\beta} \|^2,\]where \(T_{WW} = \mathrm{tr}(W^\top W + W^2)\), \(M_X = I - X(X^\top X)^{-1} X^\top\) is the OLS annihilator, \(\bar{\sigma}^2\) is the posterior mean of \(\sigma^2\), and \(\bar{\beta}\) is the posterior mean of \(\beta\). The projected term \(\| M_X W X \bar{\beta} \|^2\) is the same Schur-complement quantity that appears in spreg’s
lmLagdenominator (Anselin 1996 derivation), evaluated at the posterior-mean \(\beta\) rather than the OLS estimate.The per-draw LM statistic is
\[\mathrm{LM}^{(d)} = \frac{\bigl(S^{(d)}\bigr)^2}{V} \;\xrightarrow{d}\; \chi^2_1 \quad \text{under } H_0,\]and the Bayesian p-value is computed at the posterior-mean LM ([Doğan et al., 2021], eq. 3.7).
- Parameters:¶
- model : SpatialModel¶
Fitted OLS-like model with
inference_dataattribute providing posterior draws ofbetaandsigma, plus the cached_y,_X,_Wy,_T_wwattributes.
- Returns:¶
Per-draw LM samples, summary statistics,
df=1and metadata.- Return type:¶