Reputation: 1
I would like to see if there's spatial autocorrelation of a measured y for the vertices of my network. The vertices are somewhat clustered. Non-connected vertices I assume to be independent. So essentially it's autocorrelation on a cluster basis (ideally also for all clusters seperately, because for the clusters the degree of autocorrelation might be very different.
Here's what I've done so far:
library(statnet)
library(ncf)
data <- data.frame("id" = 1:100, "cluster" = c(rep(1:7, each = 10), 8:37), "y" = rnorm(100, 0, 1))
grid <- expand.grid(1:100, 1:100)
grid$overlap <- ifelse(data$cluster[grid$Var1] == data$cluster[grid$Var2], 1, 0)
grid$overlap[grid$overlap == 1] <- unlist(lapply(grid$overlap[grid$overlap == 1],
function(x)
ifelse(runif(1, 0, 100) < (.5 / 2 * 100), 1, 0)))
connect_mat <- matrix(data = grid$overlap, nrow = 100, ncol = 100, byrow = T)
net <- as.network(connect_mat, directed = F)
coord_net <- gplot(net, gmode = "graph")
corlog <- correlog(coord_net[, 1], coord_net[, 2], paper$effect, increment = 1)
plot(corlog)
Example network Correlogram of example network
This is just for illustrating what I want, here I of course don't expect any autocorrelation. For now I have used the coordinates of the vertices in the network plot to look at autocorrelation. There are a few reasons I don't want to do this:
These points could (hopefully) all be fixed if I, instead of the coordinates, used the geodesic distances between vertices (i.e. how many steps do I need to get from one vertice to another). So all members of the same cluster would have distances from 1 to 5 roughly and Inf to all others.
Soo my question is essentially: Is there a way to give correlog a distance matrix (that involves Inf) instead of x and y coordinates? Or maybe a better way of using the coordinates that returns consistent results and includes the clustering of the network?
Upvotes: 0
Views: 75