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):

  1. Score \(s_\rho(\theta)\) evaluated at every posterior draw of \((\beta, \sigma^2)\) from the OLS null fit.

  2. Concentration matrix \(C_{\rho\rho \cdot \beta}(\theta^\star)\) evaluated at the posterior mean \(\theta^\star\) (Doğan eq. 3.6).

  3. 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 lmLag denominator (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_data attribute providing posterior draws of beta and sigma, plus the cached _y, _X, _Wy, _T_ww attributes.

Returns:

Per-draw LM samples, summary statistics, df=1 and metadata.

Return type:

BayesianLMTestResult