I posted this question on StackOverflow a while back but received no answer.? I have 9,150 polygons in my data set. I was trying to run a spatial autoregressive model (SAR) in?spdep?to test spatial dependence of my outcome variable. After running the model, I wanted to examine the direct/indirect impacts, but encountered an error that seems to have something to do with the length of neighbors in the weights matrix not being equal to?n. I tried running the very same equation as SLX model (Spatial Lag X), and?impacts()?worked fine, even though there were some polygons in my set that had no neighbors.?
# Defining queen contiguity neighbors for polyset and storing the matrix as list q.nbrs <- poly2nb(polyset) listweights <- nb2listw(q.nbrs, zero.policy = TRUE)
# Defining the model model.equation <- TIME ~ A + B + C
# Run SAR model reg <- lagsarlm(model.equation, data = polyset, listw = listweights, zero.policy = TRUE)
# Run impacts() to show direct/indirect impacts impacts(reg, listw = listweights, zero.policy = TRUE)
Error in intImpacts(rho = rho, beta = beta, P = P, n = n, mu = mu, Sigma = Sigma,??:
? ? length(listweights$neighbours) == n is not TRUE What am I doing wrong? I am running Windows 10 machine with R 3.5.3 with the most up-to-date spdep package, if it helps. Thank you very much. Regards, Denys Dukhovnov