计算SARMA空间回归模型:
model_sarma <- stslshac(M1$ln_VHV_NJB ~ M1$ln_BevDich + M1$ln_EZKK_HH + M1$ALQ_ZMDB + M1$BEV_Hochsc + M1$JugendAbhQ +
M1$AusAnt_202 + M1$ln_DS_VuFD + M1$Agenturen_,
listw = GewMat_idw, distance = dm_iw_dist, type = "Epanechnikov")
我收到以下错误:
stslshac中的错误(M1 $ ln_VHV_NJB〜M1 $ ln_BevDich + M1 $ ln_EZKK_HH + M1 $ ALQ_ZMDB +: 距离度量不是距离对象
“ listw”参数:
> class(GewMat_idw)
[1] "listw" "nb"
是从IDW矩阵(到所有多边形质心的反大地距离)生成的。 这里是IDW矩阵的示例:
9529 31141 12113 2197 10582
9529 0.000000e+00 7.361667e-06 3.454240e-05 8.859038e-06 7.941976e-06
31141 7.361667e-06 0.000000e+00 8.833693e-06 2.482100e-05 8.186566e-06
12113 3.454240e-05 8.833693e-06 0.000000e+00 1.032842e-05 1.005975e-05
2197 8.859038e-06 2.482100e-05 1.032842e-05 0.000000e+00 7.203990e-06
10582 7.941976e-06 8.186566e-06 1.005975e-05 7.203990e-06 0.000000e+00
without scientific notation:
9529 31141 12113 2197 10582
9529 0.000000000000 0.000007361667 0.000034542404 0.000008859038 0.000007941976
31141 0.000007361667 0.000000000000 0.000008833693 0.000024821001 0.000008186566
12113 0.000034542404 0.000008833693 0.000000000000 0.000010328419 0.000010059752
2197 0.000008859038 0.000024821001 0.000010328419 0.000000000000 0.000007203990
10582 0.000007941976 0.000008186566 0.000010059752 0.000007203990 0.000000000000
确保距离矩阵到dist对象的转换不正确。
> class(dm_iw)
[1]“矩阵”
转换为dist对象:
dm_iw_dist <- as.dist(dm_iw)
> class(dm_iw_dist)
[1] "dist"
> dim(dm_iw_dist)
NULL
也许“ dist”函数无法使用大地距离进行计算? 我还尝试根据UTM坐标创建一个新的距离矩阵以计算欧几里得距离矩阵:
> head(lonlat_utm)
x y
9529 437205.9 5806351
31141 570731.4 5831029
12113 457649.8 5826833
2197 549630.0 5796726
10582 488497.9 5921291
42217 515749.4 5865665
dm_eucl <- dist(lonlat_utm, method = "euclidean", diag = T)
dm_eucl
9529 31141 12113 2197 10582 42217 24317 12168
9529 0.000000
31141 135786.959128 0.000000
42295 602 23461 42126 25150 13285 13321 42342
9529
31141
40211 8822 24419 33307 88233 31505 52642 6359
9529
31141
32202 608833 25707 25296 22162 566 23472 22093
对于大地距离矩阵,我使用了“ geosphere”软件包中的“ distm”函数:
dm <- distm(lonlat, fun = distVincentyEllipsoid)
并获得正确的矩阵。
有人建议为什么我在dist转换后得到0维对象?
我将不胜感激...