Question

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.

Any advice would be appreciated and please ask if there is any information you would find helpful.

Était-ce utile?

La solution

Following the approach in Dormann et al. (2007), you could do something like this:

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. enter image description here

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top