bayespecon.diagnostics.bayesian_lmtests.bayesian_lm_slx_error_joint_test

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

Bayesian joint LM test for SDEM (H₀: λ = 0 AND γ = 0).

Tests the joint null hypothesis that both the spatial error coefficient and the WX coefficients are zero, i.e., whether the OLS model should be extended to an SDEM specification. Follows the multi-parameter Bayesian LM test framework of Doğan et al. [2021] and the classical joint LM-SLX-Error test of Koley and Bera [2024].

The null model is OLS. For each posterior draw from the OLS model, residuals are:

\[\mathbf{e} = \mathbf{y} - X \beta\]

The joint score vector is:

\[\begin{split}\mathbf{g} = \begin{pmatrix} \mathbf{e}^\top W \mathbf{e} \\ (WX)^\top \mathbf{e} \end{pmatrix}\end{split}\]

a \((1 + k_{wx}) \times 1\) vector for each draw. The concentration matrix is the information matrix evaluated at the posterior mean:

\[\begin{split}J = \begin{pmatrix} \mathrm{tr}(W'W + W^2) & 0 \\ 0 & \frac{1}{\bar{\sigma}^2} (WX)^\top (WX) \end{pmatrix}\end{split}\]

where \(\bar{\sigma}^2\) is the posterior mean of \(\sigma^2\). The off-diagonal blocks are zero under H₀ (spherical errors). The LM statistic for each draw is:

\[\mathrm{LM} = \mathbf{g}^\top J^{-1} \mathbf{g}\]

which is distributed as \(\chi^2_{1 + k_{wx}}\) under H₀.

Parameters:
model : SpatialModel

Fitted OLS model instance with inference_data attribute containing posterior draws for beta and sigma.

Returns:

Dataclass containing LM samples, summary statistics, and metadata. The df field is set to \(1 + k_{wx}\).

Return type:

BayesianLMTestResult