小编jlo*_*pez的帖子

用4000条记录计算Moran's I

我在树木种植园有4000个体积记录.我需要计算整个种植园的莫兰一世.我使用ape库因为据说spdep较慢.我的代码是这样的:

# Modified from http://www.ats.ucla.edu/stat/r/faq/morans_i.htm
require(ape)
df <- data.frame(
     x = 1:2000,
     y = 1:2000,
     v = rnorm(4000, mean=4) )
df.dists <- as.matrix(dist(cbind(df$x, df$y)))
df.dists.inv <- 1/df.dists
diag(df.dists.inv) <- 0
Moran.I(df$v, df.dists.inv)
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,我会遇到类似溢出的错误.

*Error in if (obs <= ei) 2 * pv else 2 * (1 - pv) : 
  missing value where TRUE/FALSE needed*
Run Code Online (Sandbox Code Playgroud)

使用ff库

require(ape)
require(ff)
ffdf <- as.ffdf(df)
ffdf.dists <- as.matrix(dist(cbind(ffdf$x, ffdf$y)))
ffdf.dists.inv <- 1/df.dists
diag(ffdf.dists.inv) <- 0
Moran.I(ffdf$v, ffdf.dists.inv)
Run Code Online (Sandbox Code Playgroud)

更多错误消息:

*Error in x …
Run Code Online (Sandbox Code Playgroud)

parallel-processing r ape-phylo spdep

9
推荐指数
1
解决办法
2510
查看次数

标签 统计

ape-phylo ×1

parallel-processing ×1

r ×1

spdep ×1