7  Tests of spatial autocorrelation, model specification

7.1 Univariate tests of spatial autocorrelation

library(spdep)
Loading required package: spData
Loading required package: sf
Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
lw <- nb2listw(unb, style="W")
moran.test(eng324$realNetPre, listw=lw, randomisation=TRUE, alternative="two.sided")

    Moran I test under randomisation

data:  eng324$realNetPre  
weights: lw    

Moran I statistic standard deviate = 6.9357, p-value = 4.042e-12
alternative hypothesis: two.sided
sample estimates:
Moran I statistic       Expectation          Variance 
      0.244871308      -0.003095975       0.001278221 

Moran’s I is given as (Cliff and Ord 1981, 17):

I = \frac{n \sum_{(2)} w_{ij} z_i z_j}{S_0 \sum_{i=1}^{n} z_i^2}

where x_i, i=1, \ldots, n are n observations on the numeric variable of interest, z_i = x_i - \bar{x}, \bar{x} = \sum_{i=1}^{n} x_i / n, \sum_{(2)} = \stackrel{\sum_{i=1}^{n} \sum_{j=1}^{n}}{i \neq j}, w_{ij} are the spatial weights, and S_0 = \sum_{(2)} w_{ij}. A comparison of implementations of measures of spatial autocorrelation shows that a wide range of measures is available in R in a number of packages, chiefly in the spdep package, and that differences from other implementations can be attributed to design decisions (Bivand and Wong 2018). The spdep package also includes the only implementations of exact and Saddlepoint approximations to global Moran’s I (Tiefelsdorf 2002; Bivand, Müller, and Reder 2009).

Global measures of spatial autocorrelation using spatial weights objects based on graphs of neighbours are, as we have seen, rather blunt tools, which for interpretation depend critically on a reasoned mean model of the variable in question. If the mean model is just the intercept, the global measures will respond to all kinds of mis-specification, not only spatial autocorrelation (Schabenberger and Gotway 2005; McMillen 2003).

7.2 Tests of residual spatial autocorrelation

When the model is the null model, containing only the intercept, the univariate test moran.test on the residuals with randomisation=FALSE and the test on residuals lm.morantest are the same:

lm_null <- lm(realNetPre ~ 1, data=eng324)
moran.test(residuals(lm_null), listw=lw,
 randomisation=FALSE, alternative="two.sided")

    Moran I test under normality

data:  residuals(lm_null)  
weights: lw    

Moran I statistic standard deviate = 6.7433, p-value = 1.548e-11
alternative hypothesis: two.sided
sample estimates:
Moran I statistic       Expectation          Variance 
      0.244871308      -0.003095975       0.001352204 
lm.morantest(lm_null, listw=lw, alternative="two.sided")

    Global Moran I for regression residuals

data:  
model: lm(formula = realNetPre ~ 1, data = eng324)
weights: lw

Moran I statistic standard deviate = 6.7433, p-value = 1.548e-11
alternative hypothesis: two.sided
sample estimates:
Observed Moran I      Expectation         Variance 
     0.244871308     -0.003095975      0.001352204 

If we move to a model with independent variables, we will see that the inferences are not the same:

form_pre <- log(realNetPre) ~ log(units) + house +
 log(dens) + Metrop + log(realWgPre)
lm_obj_pre <- lm(form_pre, data=eng324)
moran.test(residuals(lm_obj_pre), listw=lw,
 randomisation=FALSE, alternative="two.sided")

    Moran I test under normality

data:  residuals(lm_obj_pre)  
weights: lw    

Moran I statistic standard deviate = 4.521, p-value = 6.156e-06
alternative hypothesis: two.sided
sample estimates:
Moran I statistic       Expectation          Variance 
      0.163150227      -0.003095975       0.001352204 
lm.morantest(lm_obj_pre, listw=lw, alternative="two.sided")

    Global Moran I for regression residuals

data:  
model: lm(formula = form_pre, data = eng324)
weights: lw

Moran I statistic standard deviate = 4.7671, p-value = 1.869e-06
alternative hypothesis: two.sided
sample estimates:
Observed Moran I      Expectation         Variance 
     0.163150227     -0.010433124      0.001325885 

This is because lm.morantest takes into account the structure of the regression model, as do lm.morantest.sad and lm.morantest.exact:

lm.morantest.sad(lm_obj_pre, listw=lw, alternative="two.sided")

    Saddlepoint approximation for global Moran's I (Barndorff-Nielsen
    formula)

data:  
model:lm(formula = form_pre, data = eng324)
weights: lw

Saddlepoint approximation = 4.4651, p-value = 8.004e-06
alternative hypothesis: two.sided
sample estimates:
Observed Moran I 
       0.1631502 
lm.morantest.exact(lm_obj_pre, listw=lw, alternative="two.sided")

    Global Moran I statistic with exact p-value

data:  
model:lm(formula = form_pre, data = eng324)
weights: lw

Exact standard deviate = 4.4649, p-value = 8.01e-06
alternative hypothesis: two.sided
sample estimates:
[1] 0.1631502

In all these cases, the measured value of Moran’s I is the same, but the inferences differ somewhat.

7.3 Model specification

A recent review of spatial regression in a spatial econometrics setting is given by Kelejian and Piras (2017); note that their usage is to call the spatial coefficient of the lagged response \lambda and that of the lagged residuals \rho, the reverse of other usage (Anselin 1988; J. P. LeSage and Pace 2009); here we use \rho_{\mathrm{Lag}} for the spatial coefficient in the spatial lag model, and \rho_{\mathrm{Err}} for the spatial error model. One interesting finding is that relatively dense spatial weights matrices may downweight model estimates, suggesting that sparser weights are preferable (Smith 2009). Another useful finding is that the presence of residual spatial autocorrelation need not bias the estimates of variance of regression coefficients, provided that the covariates themselves do not exhibit spatial autocorrelation (Smith and Lee 2012).

In trying to model these spatial processes, we may choose to model the spatial autocorrelation in the residual with a spatial error model (SEM).

{\mathbf y} = {\mathbf X}{\mathbf \beta} + {\mathbf u}, \qquad {\mathbf u} = \rho_{\mathrm{Err}} {\mathbf W} {\mathbf u} + {\mathbf \varepsilon},

where {\mathbf y} is an (N \times 1) vector of observations on a response variable taken at each of N locations, {\mathbf X} is an (N \times k) matrix of covariates, {\mathbf \beta} is a (k \times 1) vector of parameters, {\mathbf u} is an (N \times 1) spatially autocorrelated disturbance vector, {\mathbf \varepsilon} is an (N \times 1) vector of independent and identically distributed disturbances and \rho_{\mathrm{Err}} is a scalar spatial parameter.

If the processes in the covariates and the response match, we should find little difference between the coefficients of a least squares and a SEM, but very often they diverge, suggesting that a Hausman test for this condition should be employed (Pace and LeSage 2008). This may be related to earlier discussions of a spatial equivalent to the unit root and cointegration where spatial processes match (Fingleton 1999).

A model with a spatial process in the response only is termed a spatial lag model (SLM, often SAR - spatial autoregressive) (J. P. LeSage and Pace 2009).

{\mathbf y} = \rho_{\mathrm{Lag}} {\mathbf W}{\mathbf y} + {\mathbf X}{\mathbf \beta} + {\mathbf \varepsilon}, where \rho_{\mathrm{Lag}} is a scalar spatial parameter.

Work reviewed by Mur and Angulo (2006) on the Durbin model; the Durbin model adds the spatially lagged covariates to the covariates included in the spatial lag model, giving a spatial Durbin model (SDM) with different processes in the response and covariates:

{\mathbf y} = \rho_{\mathrm{Lag}} {\mathbf W}{\mathbf y} + {\mathbf X}{\mathbf \beta} + {\mathbf W}{\mathbf X}{\mathbf \gamma} + {\mathbf \varepsilon},

where {\mathbf \gamma} is a (k' \times 1) vector of parameters. k' defines the subset of the intercept and covariates, often k' = k-1 when using row standardised spatial weights and omitting the spatially lagged intercept.

This permits the spatial processes to be viewed and tested for as a Common Factor (Burridge 1981; Bivand 1984). The inclusion of spatially lagged covariates lets us check whether the same spatial process is manifest in the response and the covariates (SEM), whether they are different processes, or whether no process is detected. The Common Factor is present when {\mathbf \gamma} = - \rho_{\mathrm{Lag}} {\mathbf \beta}:

{\mathbf y} = \rho_{\mathrm{Lag}} {\mathbf W}{\mathbf y} + {\mathbf X}{\mathbf \beta} - \rho_{\mathrm{Lag}} {\mathbf W}{\mathbf X} {\mathbf \beta} + {\mathbf \varepsilon}, \qquad ({\mathbf I} - \rho_{\mathrm{Lag}} {\mathbf W}){\mathbf y} = ({\mathbf I} - \rho_{\mathrm{Lag}} {\mathbf W}) {\mathbf X}{\mathbf \beta} + {\mathbf \varepsilon}, where {\mathbf I} is the N \times N identity matrix, and {\mathbf I} - \rho_{\mathrm{Lag}} {\mathbf W} is the Common Factor:

\qquad {\mathbf y} = {\mathbf X}{\mathbf \beta} + ({\mathbf I} - \rho_{\mathrm{Lag}} {\mathbf W})^{-1} {\mathbf \varepsilon}, \qquad {\mathbf y} = {\mathbf X}{\mathbf \beta} + {\mathbf u}, \qquad {\mathbf u} = \rho_{\mathrm{Err}} {\mathbf W} {\mathbf u} + {\mathbf \varepsilon},

If we extend this family with processes in the covariates and the residual, we get a spatial error Durbin model (SDEM). If it is chosen to admit a spatial process in the residuals in addition to a spatial process in the response, again two models are formed, a general nested model (GNM) nesting all the others, and a model without spatially lagged covariates (SAC, also known as SARAR - Spatial AutoRegressive-AutoRegressive model). If neither the residuals nor the residual are modelled with spatial processes, spatially lagged covariates may be added to a linear model, as a spatially lagged X model (SLX) (Elhorst 2010; Bivand 2012; J. LeSage 2014; Halleck Vega and Elhorst 2015).

We can write the general nested model (GNM) as:

{\mathbf y} = \rho_{\mathrm{Lag}} {\mathbf W}{\mathbf y} + {\mathbf X}{\mathbf \beta} + {\mathbf W}{\mathbf X}{\mathbf \gamma} + {\mathbf u}, \qquad {\mathbf u} = \rho_{\mathrm{Err}} {\mathbf W} {\mathbf u} + {\mathbf \varepsilon},

This may be constrained to the double spatial coefficient model SAC/SARAR by setting {\mathbf \gamma} = 0, to the spatial Durbin (SDM) by setting \rho_{\mathrm{Err}} = 0, and to the error Durbin model (SDEM) by setting \rho_{\mathrm{Lag}} = 0. Imposing more conditions gives the spatial lag model (SLM) with {\mathbf \gamma} = 0 and \rho_{\mathrm{Err}} = 0, the spatial error model (SEM) with {\mathbf \gamma} = 0 and \rho_{\mathrm{Lag}} = 0, and the spatially lagged X model (SLX) with \rho_{\mathrm{Lag}} = 0 and \rho_{\mathrm{Err}} = 0.

The specification problem is then to choose between (from most complex to simplest): GNM (three sets of spatial parameters: \rho_{\mathrm{Lag}}, \rho_{\mathrm{Err}}, {\mathbf \gamma}), SAC, SDM or SDEM (two sets of spatial parameters among the three), SEM, SLM, SLX (one set of spatial parameters among the three) or ordinary least squares (no spatial parameters) - assuming that the dependent variable is Gaussian. Effectively the same specification choice is present with limited dependent variables.

7.4 Rao’s score (Lagrange multiplier) tests

When working over 25 years ago on Bivand and Szymanski (2000), the only Rao’s score (Lagrange multiplier) tests available were those newly proposed by Anselin et al. (1996). The underlying concern is to test whether the spatial parameter of interest could be taken as zero, without estimating the parameter. One works from the information matrix of the spatial model; in the case of the first tests, a mixed regressive-spatial autoregressive model with a spatial autoregressive disturbance (SAC) was considered, as this had also been used for residual autocorrelation in an SLM model. Five tests are proposed, a test for missing \rho_{\mathrm{Lag}} {\mathbf W}{\mathbf y}, "RSlag" and pointing to SLM, another for missing \rho_{\mathrm{Err}} {\mathbf W} {\mathbf u}, "RSerr" pointing to SEM, two tests matching the first two tests but adjusted for the presence of the other ("adjRSlag", "adjRSerr"), and a "SARMA" test combining both alternatives, equal to "RSlag" plus "adjRSerr" and "RSerr" plus "adjRSlag".

summary(lm.RStests(lm_obj_pre, listw=lw, test="all"))
    Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
    dependence
data:  
model: lm(formula = form_pre, data = eng324)
test weights: lw
 
         statistic parameter   p.value    
RSerr      19.3936         1 1.064e-05 ***
RSlag      13.4536         1 0.0002445 ***
adjRSerr    7.8798         1 0.0049990 ** 
adjRSlag    1.9398         1 0.1636931    
SARMA      21.3333         2 2.331e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Here, for the independent variables initially included in the model to account for the logarithm of real net expenditure on garbage collection in each district, the logarithm of the number of pick-up points (units), the proportion of dwellings among the pick-up points (house), the logarithm of pick-up point density (dens), a categorical variable Metrop with levels: "district", "london", "metrop", and the logarithm of the real regional wage rate for regions. In this case, the tests point to a SEM model rather than an SLM model or falling back to OLS.

Koley and Bera (2022) propose a similar set of tests to distinguish between either an SLM or an SLX model based on an SDM model, falling back to ordinary least squares if neither alternative is chosen. Because the interpretation of spatially lagged categorical variables is unclear, we drop Metrop from the tests

summary(SD.RStests(lm_obj_pre, listw=lw, test="SDM",
 Durbin=update(form_pre, ~ . - Metrop)))
    Rao's score test spatial Durbin diagnostics
data:  
model: lm(formula = form_pre, data = eng324)
weights: lw
Durbin: ~ log(realNetPre) log(units) + house + log(dens) + log(realWgPre)
 
             statistic parameter   p.value    
SDM_RSlag      13.4536         1 0.0002445 ***
SDM_adjRSlag   22.4480         1 2.159e-06 ***
SDM_RSWX        9.0301         4 0.0603510 .  
SDM_adjRSWX    18.0246         4 0.0012205 ** 
SDM_Joint      31.4781         5 7.536e-06 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

In this case, an SLX model appears to be indicated rather than SDM, SLM or OLS. However, we also need to look at SDEM as the tests against SAC indicated SEM rather than SLM. Koley (2024) proposes approriate tests:

summary(SD.RStests(lm_obj_pre, listw=lw, test="SDEM",
 Durbin=update(form_pre, ~ . - Metrop)))
    Rao's score test spatial Durbin diagnostics
data:  
model: lm(formula = form_pre, data = eng324)
weights: lw
Durbin: ~ log(realNetPre) log(units) + house + log(dens) + log(realWgPre)
 
           statistic parameter   p.value    
SDEM_RSerr   19.3936         1 1.064e-05 ***
SDEM_RSWX     9.0301         4   0.06035 .  
SDEM_Joint   28.4237         5 3.007e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

which indicate SEM rather than SDEM. Clearly, the underlying difficulty is that the GNM is poorly identified, and as Koley (2024) finds:

… identification conditions have not been established for the GNS model in the spatial literature that also suffers from an identification problem. In fact, to the best of our knowledge, the non-identification of the GNS model has not yet been analytically studied in the literature (Koley 2024, 3).

However, it has been found that the lm.RStests tests can be used on a fitted SLX model using the lmSLX function in spatialreg (Koley 2024, 18), again omitting Metrop from the {\mathbf W}{\mathbf X} term in addition to omitting the intercept:

library(spatialreg)
SLX_obj <- lmSLX(form_pre, data=eng324, listw=lw,
 Durbin=update(form_pre, ~ . - Metrop))
summary(lm.RStests(SLX_obj, listw=lw, test="all"))
    Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
    dependence
data:  
model: lm(log(realNetPre) ~ log.units. + house + log.dens. +
Metroplondon + Metropmetrop + log.realWgPre. + lag.log.units. +
lag.house + lag.log.dens. + lag.log.realWgPre., data = eng324, listw =
lw)
test weights: lw
 
             statistic parameter   p.value    
GNM_RSerr       16.835         1 4.077e-05 ***
GNM_RSlag       20.833         1 5.011e-06 ***
GNM_adjRSerr    12.116         1 0.0004998 ***
GNM_adjRSlag    16.114         1 5.964e-05 ***
GNM_SARMA       32.949         2 7.000e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

In Bivand and Szymanski (2000), it was found that the inclusion of the categorical variable Majority, with levels: "coalition", "conservative" and "labour", as anecdotal reports indicated that neighbouring districts with the same political party in control shared more information than otherwise, so the yardstick used would be weighted towards the same political party:

form_pre_maj <- update(form_pre, . ~. + Majority)
lm_obj_pre_maj <- lm(form_pre_maj, data=eng324)
summary(lm.RStests(lm_obj_pre_maj, listw=lw, test="all"))
    Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
    dependence
data:  
model: lm(formula = form_pre_maj, data = eng324)
test weights: lw
 
         statistic parameter   p.value    
RSerr       8.1354         1 0.0043410 ** 
RSlag      11.2331         1 0.0008035 ***
adjRSerr    1.4132         1 0.2345225    
adjRSlag    4.5109         1 0.0336791 *  
SARMA      12.6463         2 0.0017943 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The tests here indicate some support for the inclusion of \rho_{\mathrm{Lag}} {\mathbf W}{\mathbf y}. On turning to the new tests for SDM compared to SLM or SLX:

summary(SD.RStests(lm_obj_pre_maj, listw=lw, test="SDM"),
 Durbin=update(form_pre_maj, ~ . - Metrop - Majority))
    Rao's score test spatial Durbin diagnostics
data:  
model: lm(formula = form_pre_maj, data = eng324)
weights: lw
 
             statistic parameter   p.value    
SDM_RSlag      11.2331         1 0.0008035 ***
SDM_adjRSlag    8.1354         1 0.0043410 ** 
SDM_RSWX       38.6726         8 5.653e-06 ***
SDM_adjRSWX    35.5749         8 2.100e-05 ***
SDM_Joint      46.8079         9 4.262e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

There is as yet very little experience of interpreting the outcomes, but here an SDM seems to be indicated; we turn to the next set of tests:

summary(SD.RStests(lm_obj_pre_maj, listw=lw, test="SDEM"),
 Durbin=update(form_pre_maj, ~ . - Metrop - Majority))
    Rao's score test spatial Durbin diagnostics
data:  
model: lm(formula = form_pre_maj, data = eng324)
weights: lw
 
           statistic parameter   p.value    
SDEM_RSerr    8.1354         1  0.004341 ** 
SDEM_RSWX    38.6726         8 5.653e-06 ***
SDEM_Joint   46.8079         9 4.262e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

but the SDEM versus SLX or SEM also looks feasible. Testing the fitted SLX model appears to point to the SDM model rather than the SDEM model:

library(spatialreg)
SLX_obj_pre_maj <- lmSLX(form_pre_maj, data=eng324, listw=lw,
 Durbin=update(form_pre_maj, ~ . - Metrop - Majority))
summary(lm.RStests(SLX_obj_pre_maj, listw=lw, test="all"))
    Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
    dependence
data:  
model: lm(log(realNetPre) ~ log.units. + house + log.dens. +
Metroplondon + Metropmetrop + log.realWgPre. + MajorityCONS +
MajorityLAB + lag.log.units. + lag.house + lag.log.dens. +
lag.log.realWgPre., data = eng324, listw = lw)
test weights: lw
 
             statistic parameter   p.value    
GNM_RSerr       3.7201         1  0.053760 .  
GNM_RSlag      10.6248         1  0.001116 ** 
GNM_adjRSerr   16.3201         1 5.349e-05 ***
GNM_adjRSlag   23.2247         1 1.441e-06 ***
GNM_SARMA      26.9449         2 1.409e-06 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Of course, we should repeat these exercises for the post-CCT net expenditures:

form_post <- update(form_pre, log(realNetPst) ~ . - log(realWgPre) + log(realWgPst))
form_post_maj <- update(form_post, . ~ . + Majority)
lm_obj_post <- lm(form_post, data=eng324)
summary(lm.RStests(lm_obj_post, listw=lw, test="all"))
    Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
    dependence
data:  
model: lm(formula = form_post, data = eng324)
test weights: lw
 
         statistic parameter   p.value    
RSerr     14.50206         1 0.0001400 ***
RSlag      7.15833         1 0.0074617 ** 
adjRSerr   7.63077         1 0.0057381 ** 
adjRSlag   0.28704         1 0.5921255    
SARMA     14.78910         2 0.0006146 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(SD.RStests(lm_obj_post, listw=lw, test="SDM",
 Durbin=update(form_post, ~ . - Metrop)))
    Rao's score test spatial Durbin diagnostics
data:  
model: lm(formula = form_post, data = eng324)
weights: lw
Durbin: ~ log(realNetPst) log(units) + house + log(dens) + log(realWgPst)
 
             statistic parameter   p.value    
SDM_RSlag       7.1583         1 0.0074617 ** 
SDM_adjRSlag   18.0764         1 2.122e-05 ***
SDM_RSWX        7.6105         4 0.1069333    
SDM_adjRSWX    18.5285         4 0.0009725 ***
SDM_Joint      25.6869         5 0.0001026 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(SD.RStests(lm_obj_post, listw=lw, test="SDEM",
 Durbin=update(form_post, ~ . - Metrop)))
    Rao's score test spatial Durbin diagnostics
data:  
model: lm(formula = form_post, data = eng324)
weights: lw
Durbin: ~ log(realNetPst) log(units) + house + log(dens) + log(realWgPst)
 
           statistic parameter   p.value    
SDEM_RSerr   14.5021         1 0.0001400 ***
SDEM_RSWX     7.6105         4 0.1069333    
SDEM_Joint   22.1126         5 0.0004984 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(spatialreg)
SLX_post_obj <- lmSLX(form_post, data=eng324, listw=lw,
 Durbin=update(form_post, ~ . - Metrop))
summary(lm.RStests(SLX_post_obj, listw=lw, test="all"))
    Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
    dependence
data:  
model: lm(log(realNetPst) ~ log.units. + house + log.dens. +
Metroplondon + Metropmetrop + log.realWgPst. + lag.log.units. +
lag.house + lag.log.dens. + lag.log.realWgPst., data = eng324, listw =
lw)
test weights: lw
 
             statistic parameter   p.value    
GNM_RSerr       14.119         1 0.0001716 ***
GNM_RSlag       17.930         1 2.292e-05 ***
GNM_adjRSerr    14.321         1 0.0001541 ***
GNM_adjRSlag    18.132         1 2.061e-05 ***
GNM_SARMA       32.251         2 9.926e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lm_obj_post_maj <- lm(form_post_maj, data=eng324)
summary(lm.RStests(lm_obj_post_maj, listw=lw, test="all"))
    Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
    dependence
data:  
model: lm(formula = form_post_maj, data = eng324)
test weights: lw
 
         statistic parameter  p.value   
RSerr       6.8129         1 0.009050 **
RSlag       7.0744         1 0.007819 **
adjRSerr    1.7879         1 0.181185   
adjRSlag    2.0494         1 0.152270   
SARMA       8.8623         2 0.011901 * 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(SD.RStests(lm_obj_post_maj, listw=lw, test="SDM"),
 Durbin=update(form_post_maj, ~ . - Metrop - Majority))
    Rao's score test spatial Durbin diagnostics
data:  
model: lm(formula = form_post_maj, data = eng324)
weights: lw
 
             statistic parameter   p.value    
SDM_RSlag       7.0744         1  0.007819 ** 
SDM_adjRSlag    6.8129         1  0.009050 ** 
SDM_RSWX       35.5024         8 2.165e-05 ***
SDM_adjRSWX    35.2409         8 2.417e-05 ***
SDM_Joint      42.3153         9 2.878e-06 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(SD.RStests(lm_obj_post_maj, listw=lw, test="SDEM"),
 Durbin=update(form_post_maj, ~ . - Metrop - Majority))
    Rao's score test spatial Durbin diagnostics
data:  
model: lm(formula = form_post_maj, data = eng324)
weights: lw
 
           statistic parameter   p.value    
SDEM_RSerr    6.8129         1   0.00905 ** 
SDEM_RSWX    35.5024         8 2.165e-05 ***
SDEM_Joint   42.3153         9 2.878e-06 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(spatialreg)
SLX_obj_post_maj <- lmSLX(form_post_maj, data=eng324, listw=lw,
 Durbin=update(form_post_maj, ~ . - Metrop - Majority))
summary(lm.RStests(SLX_obj_post_maj, listw=lw, test="all"))
    Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
    dependence
data:  
model: lm(log(realNetPst) ~ log.units. + house + log.dens. +
Metroplondon + Metropmetrop + log.realWgPst. + MajorityCONS +
MajorityLAB + lag.log.units. + lag.house + lag.log.dens. +
lag.log.realWgPst., data = eng324, listw = lw)
test weights: lw
 
             statistic parameter   p.value    
GNM_RSerr       4.7900         1 0.0286252 *  
GNM_RSlag       9.7710         1 0.0017728 ** 
GNM_adjRSerr    6.6243         1 0.0100599 *  
GNM_adjRSlag   11.6053         1 0.0006576 ***
GNM_SARMA      16.3953         2 0.0002753 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1