0

Good morning,
I want to perform a spatial panel regression using the splm package. To do so, I need a Spatial Weight Matrix and I would like to create Distance-Band Weights using the package spdep. I have a shapefile with 7904 elements that you can find at this link https://www.istat.it/storage/cartografia/confini_amministrativi/non_generalizzati/Limiti01012022.zip . My problem is that the resulting Spatial Weight Matrix is singular, since its determinant is 0, so I can't perform the regression. Can someone help me solving this problem?

Here is the code I run:

shapefile <- rgdal::readOGR("Com01012022_g_WGS84.shp")
coordinatess <- sp::coordinates(shapefile)
knn1 <- knearneigh(coordinatess)
str(knn1)

List of 5
$ nn : int [1:7904, 1] 14 256 71 26 297 51 185 11 7310 271 ...
$ np : int 7904
$ k : num 1
$ dimension: int 2
$ x : num [1:7904, 1:2] 404145 380314 365324 417372 375741 ...
..- attr(, "dimnames")=List of 2
.. ..$ : chr [1:7904] "0" "1" "2" "3" ...
.. ..$ : NULL
attr(
, "class")= chr "knn"
attr(*, "call")= language knearneigh(x = coordinatess)

k1 <- knn2nb(knn1)
critical.threshold <- max(unlist(nbdists(k1,coordinatess)))
critical.threshold

[1] 151173.6

nb.dist.band <- dnearneigh(coordinatess, 0, critical.threshold)
summary(nb.dist.band)

Neighbour list object:
Number of regions: 7904
Number of nonzero links: 11797252
Percentage nonzero weights: 18.8837
Average number of links: 1492.567
1 least connected region:
6761 with 1 link
1 most connected region:
997 with 3000 links

dist.band.card <- card(nb.dist.band)
dist.band.card
distbandlistw <- nb2listw(nb.dist.band, style="W")
distbandmat <- nb2mat(nb.dist.band)
det(distbandmat)

[1] 0

The error the spml regression returns is the following:

Error in h(simpleError(msg, call)) : errore durante la valutazione dell'argomento 'x' nella selezione di un metodo per la funzione 'diag': system is computationally singular

0 Answers0