如何创建 nb2listw 对象并对两个变量执行 Lee 检验?

how to create nb2listw object and perform Lee's test for two variables?

我正在尝试为两个变量计算 Lee 的统计数据。实际上,我有两点和对这两点的一些观察。

我的问题是我无法使用 nb2listw 创建权重矩阵。我试图根据两点 x 和 y 坐标创建邻居。 这里d0086和d0126是我的两个点。

d0086$x <- 227
d0086$y <- 180
d0126$x <- 282
d0126$y <- 149

cords <- cbind(d0086$x,d0126$x)
cords <- as.matrix(cords)
nb <-dnearneigh(coords,0,1000) 

然后当我尝试 运行

nb2listw(nb, style="W")

但我收到错误

error in nb2listw(dnearneigh(cords, 0, 1000), zero.policy = TRUE) : No valid observations

我不确定如何进行。你能帮我提出对两个变量执行 Lee 检验的建议吗?

https://www.rdocumentation.org/packages/spdep/versions/0.6-13/topics/lee

coords矩阵需要两点的坐标:

d0086 <- c(227, 180)
d0126 <- c(282, 149)   
coords <- cbind(d0086,d0126)

nb <- dnearneigh(coords,0,1000) 
nb2listw(nb, style="W")


###############
Characteristics of weights list object:
Neighbour list object:
Number of regions: 2 
Number of nonzero links: 2 
Percentage nonzero weights: 50 
Average number of links: 1 

Weights style: W 
Weights constants summary:
  n nn S0 S1 S2
W 2  4  2  4  8