使用 spdep 包中的函数 autocov_dist 时出现错误消息
Error message when using the function autocov_dist from spdep package
我正在使用 spdep
包中的函数 autocov_dist
来估计 aucovariate。我使用反距离作为权重。当我在我的数据上测试它时,我收到了这个错误信息:
Error in autocov_dist(Var, xy, nbs = 100, style = "B", type = "inverse") : is.vector(z) is not TRUE
这是一个可重现的示例(我在坐标中显示了较大的值,因为在我的真实数据中,空间坐标采用 UTM):
library(spdep)
set.seed <- 123
xy<- as.data.frame(cbind(rnorm(1000,100000, 100), (rnorm(1000,500000, 100))))
Var <- rnorm(1000,2, 1)
autocov <- autocov_dist(Var, xy, nbs=100, style="B",type="inverse")
另外,我在函数文档中找不到明确的定义,所以邻域半径(函数中的nbs
参数)到底是什么定义。
要设置种子,您必须使用 set.seed(number)
。
xy
需要是您已将其转换为数据框的矩阵。尝试:
library(spdep)
set.seed(123)
xy<- cbind(rnorm(1000,100000, 100), (rnorm(1000,500000, 100)))
Var <- rnorm(1000,2, 1)
autocov <- autocov_dist(Var, xy, nbs=100, style="B",type="inverse")
我正在使用 spdep
包中的函数 autocov_dist
来估计 aucovariate。我使用反距离作为权重。当我在我的数据上测试它时,我收到了这个错误信息:
Error in autocov_dist(Var, xy, nbs = 100, style = "B", type = "inverse") : is.vector(z) is not TRUE
这是一个可重现的示例(我在坐标中显示了较大的值,因为在我的真实数据中,空间坐标采用 UTM):
library(spdep)
set.seed <- 123
xy<- as.data.frame(cbind(rnorm(1000,100000, 100), (rnorm(1000,500000, 100))))
Var <- rnorm(1000,2, 1)
autocov <- autocov_dist(Var, xy, nbs=100, style="B",type="inverse")
另外,我在函数文档中找不到明确的定义,所以邻域半径(函数中的nbs
参数)到底是什么定义。
要设置种子,您必须使用 set.seed(number)
。
xy
需要是您已将其转换为数据框的矩阵。尝试:
library(spdep)
set.seed(123)
xy<- cbind(rnorm(1000,100000, 100), (rnorm(1000,500000, 100)))
Var <- rnorm(1000,2, 1)
autocov <- autocov_dist(Var, xy, nbs=100, style="B",type="inverse")