bayespecon.diagnostics.bayesian_lmtests.bayesian_lm_lag_test

bayespecon.diagnostics.bayesian_lmtests.bayesian_lm_lag_test(model)[source]

Bayesian LM test for omitted spatial lag (SAR) model.

Follows Doğan et al. [2021]. Implements the Bayesian LM test for omitted spatial lag (SAR) effects.

The test statistic for each posterior draw is:

\[S = \mathbf{e}^\top W \mathbf{y}\]

where \(\mathbf{e}\) are residuals, \(W\) is the spatial weights matrix, and \(\mathbf{y}\) is the outcome vector.

The variance is:

\[V = T_{WW} \bar{\sigma}^2 + \|W\mathbf{y}\|^2\]

where \(T_{WW} = \mathrm{tr}(W^\top W + W^2)\) and \(\bar{\sigma}^2\) is the posterior mean of \(\sigma^2\). This matches the Fisher information denominator of the classical LM-lag test ([]).

The LM statistic is:

\[\mathrm{LM} = \frac{S^2}{V}\]

The Bayesian p-value is computed at the posterior mean of the LM statistic: 1 - chi2.cdf(mean, df) ([Doğan et al., 2021]).

Parameters:
model : SpatialModel

Fitted spatial model instance with inference_data attribute.

Returns:

Dataclass containing LM samples, summary statistics, and metadata.

Return type:

BayesianLMTestResult