【问题标题】:Error message when using the function autocov_dist from spdep package使用 spdep 包中的函数 autocov_dist 时出现错误消息
【发布时间】:2021-01-16 03:40:44
【问题描述】:

我正在使用 spdep 包中的函数 autocov_dist 来估计自变量。我使用反距离作为权重。当我对我的数据进行测试时,我收到了以下错误消息:

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 参数),因为我在函数文档中找不到明确的定义。

【问题讨论】:

    标签: r geospatial correlation spatial spdep


    【解决方案1】:

    要设置种子,您必须使用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")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-10
      • 1970-01-01
      • 2020-08-16
      相关资源
      最近更新 更多