Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何创建nb2listw对象并执行Lee';两个变量的s检验?_R_Spatial_Correlation - Fatal编程技术网

R 如何创建nb2listw对象并执行Lee';两个变量的s检验?

R 如何创建nb2listw对象并执行Lee';两个变量的s检验?,r,spatial,correlation,R,Spatial,Correlation,我试图计算两个变量的李统计。事实上,我有两点和对这两点的观察 我的问题是,我无法使用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 <-dnearne

我试图计算两个变量的李统计。事实上,我有两点和对这两点的观察

我的问题是,我无法使用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) 
但我犯了一个错误

error in nb2listw(dnearneigh(cords, 0, 1000), zero.policy = TRUE) : No valid observations
我不知道如何进行。你能帮我给我一些建议,对两个变量进行李氏检验吗


坐标矩阵需要两点的坐标:

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

d0086感谢您的评论!但是,它只创建了2个点。我希望创建具有相同坐标值的行(d0086)点数。否则,我不能称之为李测试。你能给点提示吗?谢谢,我对您的代码进行了如下编辑:d0086$x要获得更详细的帮助,请发布您的数据
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