I am trying to perform some simulations on models I am testing, which have both phylogenetic and geographic networks.
我正在尝试对我正在测试的模型进行一些模拟,这些模型具有系统发育和地理网络。
I wish to test the effects of these independently to compare the methods estimation abilities on each dimension. However I am having trouble generating a continuous variable that shows significant geographic spatial auto=correlation. So far I have used average yearly temperature (this is country-level data), but this does not allow me to control the size of the spatial auto-correlation. Also it has the disadvantage of not knowing the true value of spatial auto-correlation.
我想独立测试这些方法的效果,比较方法对每个维度的估计能力。然而,我在生成一个连续变量时遇到了麻烦,该变量显示了显著的地理空间自动=相关性。到目前为止,我已经使用了平均年温度(这是*别的数据),但是这并不允许我控制空间自相关的大小。同时也存在空间自相关的真实值不知道的缺点。
I have a list of Longitude and Latitude points, and I was wondering if there was a simple or common way to generate a continuous response variable that would show spatial auto-correlation, and to be able to control the size of that correlation? Preferably within R, however, as long as they can be converted to a R-compatible format, other methods would be acceptable.
我有一个经度和纬度点的列表,我想知道是否有一种简单或通用的方法来生成一个连续的响应变量来显示空间自相关,并能够控制该相关性的大小?但是,最好是在R中,只要可以将它们转换为R兼容的格式,其他方法就可以接受。
Any advice would be appreciated and please ask if there is any information you would find helpful.
如果您有什么建议,我们将不胜感激。如果您有什么有用的信息,请咨询。
1 个解决方案
#1
4
Following the approach in Dormann et al. (2007), you could do something like this:
按照Dormann等人(2007)的方法,您可以这样做:
N <- 3000
p <- 1/N
# generate some points
set.seed(1234)
x.coord <- runif(N,0,100)
y.coord <- runif(N,0,100)
points <- cbind(x.coord,y.coord)
# distance matrix between points
Dd <- as.matrix(dist(points))
# weights matrix
w <- exp(-p * Dd)
Ww <- chol(w)
# errors
z <- t(Ww) %*% rnorm(N,0,1)
# plot
df <- data.frame(x = x.coord, y = y.coord, z = z)
require(ggplot2)
ggplot(df, aes(x = x, y = y, col = z)) +
geom_point() +
scale_colour_gradient(low="red", high="white")
where variable p controls the size of auto-correlation (here I set it to 1/3000 = 0.000333). p = 0 would be no correlation.
变量p控制自相关的大小(这里我将其设置为1/3000 = 0.000333)。p = 0没有相关性。
Reference: Dormann, C. F., McPherson, J. M., Araujo, M. B., Bivand, R., Bolliger, J., Carl, G., … Wilson, R. (2007). Methods to account for spatial autocorrelation in the analysis of species distributional data: a review. Ecography, 30(5), 609–628.
参考:Dormann,c F。麦克弗森,j . M。、Araujo m B。Bivand,R。斯特凡,J。卡尔,G。,……威尔逊,R.(2007)。在物种分布数据分析中考虑空间自相关的方法:综述。描述生态学,30(5),609 - 628。
#1
4
Following the approach in Dormann et al. (2007), you could do something like this:
按照Dormann等人(2007)的方法,您可以这样做:
N <- 3000
p <- 1/N
# generate some points
set.seed(1234)
x.coord <- runif(N,0,100)
y.coord <- runif(N,0,100)
points <- cbind(x.coord,y.coord)
# distance matrix between points
Dd <- as.matrix(dist(points))
# weights matrix
w <- exp(-p * Dd)
Ww <- chol(w)
# errors
z <- t(Ww) %*% rnorm(N,0,1)
# plot
df <- data.frame(x = x.coord, y = y.coord, z = z)
require(ggplot2)
ggplot(df, aes(x = x, y = y, col = z)) +
geom_point() +
scale_colour_gradient(low="red", high="white")
where variable p controls the size of auto-correlation (here I set it to 1/3000 = 0.000333). p = 0 would be no correlation.
变量p控制自相关的大小(这里我将其设置为1/3000 = 0.000333)。p = 0没有相关性。
Reference: Dormann, C. F., McPherson, J. M., Araujo, M. B., Bivand, R., Bolliger, J., Carl, G., … Wilson, R. (2007). Methods to account for spatial autocorrelation in the analysis of species distributional data: a review. Ecography, 30(5), 609–628.
参考:Dormann,c F。麦克弗森,j . M。、Araujo m B。Bivand,R。斯特凡,J。卡尔,G。,……威尔逊,R.(2007)。在物种分布数据分析中考虑空间自相关的方法:综述。描述生态学,30(5),609 - 628。