bayespecon.diagnostics.bayesian_lmtests.bayesian_lm_error_test

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

Bayesian LM test for omitted spatial error (SEM) model.

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

For each posterior draw, the test statistic is:

\[S = \sum_{i} e_i (W \mathbf{e})_i\]

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

The variance is:

\[V = T_{WW} \bar{\sigma}^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-error 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