Skip to content
Prev 28302 / 29559 Next

eigenvectors increase spatial autocorrelation in ols regression

On Thu, 23 Jul 2020, Vinicius Maia wrote:

            
I do not have my copy of Cliff & Ord (1973) to hand. The value of Moran's 
I is the same, but the inferences will be affected by changes in the 
expectation and variance (under Normality):

library(spdep)
columbus <- st_read(system.file("shapes/columbus.shp",
   package="spData")[1])
col.gal.nb <- read.gal(system.file("weights/columbus.gal",
   package="spData")[1])
OLS <- lm(CRIME ~ INC + HOVAL, data=columbus)
lm.morantest(OLS, listw=nb2listw(col.gal.nb))
moran.test(residuals(OLS), listw=nb2listw(col.gal.nb),
   randomisation=FALSE)

This is because standard regression assumptions affect how we view the 
regression residuals, details in Cliff & Ord. See for example the code in 
moran.test() for E(I) (var(I) is similar):

     EI <- (-1)/wc$n1

where wc$n1 is n - 1 from spweights.constants(). In the lm.morantest() 
case:

     XtXinv <- chol2inv(model$qr$qr[p1, p1, drop = FALSE])
     X <- model.matrix(terms(model), model.frame(model))
     if (length(nacoefs) > 0L)
         X <- X[, -nacoefs]
     if (!is.null(wts <- weights(model))) {
         X <- drop(t(sapply(1:length(wts), function(i) sqrt(wts[i]) *
             X[i, ])))
     }
     Z <- lag.listw(listw.U, X, zero.policy = zero.policy)
     C1 <- t(X) %*% Z
     trA <- (sum(diag(XtXinv %*% C1)))
     EI <- -((N * trA)/((N - p) * S0))

and S_0 is the sum of weights (N if row standardised), p is the number 
columns of X, and A = (X'X)^{-1} X'WX. For the distance band case, you 
also need to adjust N for the count of pairs of neighbours within that 
band; in moran.test() you see n <- as.double(length(which(cards > 0))) by 
default, where cards is a vector of neighbour counts; in lm.morantest() 
the equivalent by default is
  N <- as.double(length(which(card(listw$neighbours) > 0L)))

My presumption is that ncf::correlog() is for input variables, not 
regression residuals, as there is no argument to pass though the fitted 
model object from which to extract the model matrix or (X'X)^{-1}. 
Further, resampling regression residuals may be unsafe for similar 
reasons; the draws should not be from the residuals, I think.

Recall that the code is shown by typing the function name, and this best 
documents what is going on.

Again, refer to Cliff & Ord 1973 for the full development.

Roger