早上好,
我想使用
splm
包执行空间面板回归。为此,我需要一个空间权重矩阵,并且我想使用包 spdep
创建距离带权重。我有一个包含 7904 个元素的 shapefile,您可以在此链接中找到该文件 https://www.istat.it/storage/cartografia/confini_amministrativi/non_generalizzati/Limiti01012022.zip 。我的问题是生成的空间权重矩阵是奇异的,因为它的行列式是 0,所以我无法执行回归。有人可以帮我解决这个问题吗?
这是我运行的代码:
shapefile <- rgdal::readOGR("Com01012022_g_WGS84.shp")
coordinatess <- sp::coordinates(shapefile)
knn1 <- knearneigh(coordinatess)
str(knn1)
5 名名单
$ nn : int [1:7904, 1] 14 256 71 26 297 51 185 11 7310 271 ...
$ np:整数 7904
$ k : 数字 1
$ 维度:int 2
$ x : 数字 [1:7904, 1:2] 404145 380314 365324 417372 375741 ...
..- attr(, "dimnames")=2 的列表
.. ..$ : chr [1:7904] "0" "1" "2" "3" ...
.. ..$:空
attr(, "class")= chr "knn"
attr(*, "call")= 语言 knearneigh(x = 坐标)
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)
邻居列表对象:
区域数量:7904
非零链接数量:11797252
非零权重百分比:18.8837
平均链接数:1492.567
1 个最少连接区域:
6761 有 1 个链接
1 个连接最紧密的区域:
997 个,有 3000 个链接
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
spml
回归返回的错误如下:h(simpleError(msg, call)) 中的错误: errore durante la valutazione dell'argomento 'x' nella selezione di un method per la funzione 'diag': 系统在计算上是奇异的
我遇到了同样的问题。你找到解决办法了吗?