6
$\begingroup$

I'm trying to find statistical test (or procedure) which is able to discover patterns in spatial distribution of points. I sketch the problem by giving the example about position of bird territories and personality of birds.

1. Load this example data (they are completely fabricated). Data consists of geographical coordinates of territories and the level of aggression for each bird.

Example data:

x_coor<-rep(c(2,2.5,3,3.5,4,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,17.5,
18,18.5,19,31.5,32,32.5,33,33.5,1,1.5,2,3,4,5,16,17,18,19,20,21,22,23,24,25,
26,16,16.5,17,18,19,20,27.5,28.5,29.5,30.5,31,31.5,32,33,34,2,3,4,5,6,7,8,9,
12,13,14,15,16,18,20,21,22,23,24,25,26,28,29,30,31,32,33,34,1,7,8,10,14,22,
26,28,33),c(5,5,5,3,2,1,2,3,3,3,2,3,2,2,1,1,1,4,4,3,2,3,3,8,4,8,1,4,4,4,4,3,
2,2,2,2,2,2,3,3,3,1,1,1,3,5,5,7,1,2,3,3,3,1,5,5,5,4,1,2,2,3,2,2,3,1,2,4,3,3,
2,3,1,5,2,4,1,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2))
y_coor<-c(15,15.5,16,16.5,17,16,16.5,17,17.5,18,16,17,17.5,18,18.5,17.5,18,
18.5,18,18.5,22,22,22.5,21.5,22,22.5,21.5,22,22.5,21.5,22,22.5,21.5,22,21.5, 
22,22.5,22,22.5,22,22.5,22.5,22.5,7,6,6.5,7,7.5,5.5,6,6.5,7,5,5.5,6,16,16.5,
15,15.5,16,14,14.5,15,11,11.5,12,12.5,13,13.5,14,14.5,11.5,12,12.5,13,10,11,
12,13,14,15,16,17,18,13,14,19,20,14,15,20,21,15.5,16.5,20,21,17,18,19,20,21,
22,23,21,24,20,24,20,23.5,20,23.5,21,23.5,21,23.5,22,23,24,22,23,24,22,23,24,
23,7,6,4,5,8,2,3,4,5,8.5,1,2,3,4,8,1,2,3,4,5,6,7,16,16,17,16,17,18,16,17,18,
10,14,15,17.5,9,10,11,12,13,8,9,10,16,17,8,9,10,14,15,6,8,23,25,11,9,23,13,
25,11,15,22,18,20,14,23,16,18,20,6,3,9,1,6,22,24,4,9,19,2,12,26,11,18,10,18,
26,12,2,4,6,8,26,10,19,2,4,6,8,16,20,26,14,22,25,9,20,12,7,20,6,18,1,2,8,26,
15,15,10,4,1,25)
aggr_low<-1:35
aggr_mid<-25:65
aggr_big<-50:75
aggr_max<-70:100
aggression<-c(sample(aggr_low,75,replace=TRUE),sample(aggr_mid,100,
replace=TRUE),sample(aggr_big,62,replace=TRUE),sample(aggr_max,10,replace=TRUE))
my.data <- data.frame(x_coor, y_coor, aggression)
rbPal <- colorRampPalette(c("blue","red"))
my.data$Col <- rbPal(10)[as.numeric(cut(my.data$aggression,breaks = 10))]
par(mfrow=c(1,2))
plot(x_coor,y_coor,pch = 20,col = my.data$Col)

2. As you can see in the plot, the territories of low aggressive birds (blue) have tendency to cumulate together, whereas aggressive birds are solitary (red).

I spend a long time by searching for statistical method which could confirm such pattern (in this case clearly visible).

My first try was to correlate distance matrices of aggression of birds and spatial position of territories. Then applying mantel.test for similarity of these two matrices. This however did not work because mantel.test is unable to absorb the information about spatial isolation of clusters of low aggressive territories. It expect, that if low aggressive birds are together, they will be together all in one big cluster (not in four different clusters as visible from the plot). So mantel.test is unable to confirm or disprove the hypothesis about the influence of aggression on spatial distribution of territories.

3. I have notified that four cluster do not know about each other, thanks to long distances among them, so I try different approach.

I made again the distance matrix of all territories...

geo.dist<-dist(cbind(x_coor, y_coor))
geo.dist<-as.matrix(geo.dist)

...but I keep only distances of nearest neighbours by setting distance threshold (manually to be the 3 distance units)

geo.dist[geo.dist > 3] <- NA

This creates the imaginary circles around each territory and I was able to count the number of neighbours for each one of them.

no.neighbours<-numeric(ncol(geo.dist))
for (i in 1:ncol(geo.dist))
no.neighbours[i]<-sum(!is.na(geo.dist[ ,i]))-1

And as you can see form this plot...

plot(aggression,no.neighbours,col = my.data$Col, pch=20)

There is clear negative correlation between number of neighbours and aggression.

cor.test(aggression, no.neighbours)

Is it correct to use this steps to confirm (or falsify) this hypothesis? ("Agression of birds influence the position of territories") Does anybody know some more appropriate solution or the name of commonly used test for such problems?

$\endgroup$
  • 2
    $\begingroup$ I see (I was too hasty and did not realize it was a marked point pattern). Things I have seen before are the estimate the voronoi tessellation of the points, and see the correlation between the areas and the marked values (e.g. more aggresive should have larger territories). A similar approach to what your doing now is to formulate the spatial weights matrix and calculate the spatial correlation (e.g. Moran's I). What you are describing is negative spatial correlation. $\endgroup$ – Andy W Jul 19 '13 at 15:50
3
$\begingroup$

Moran's I is able to test if spatial correlation is present in data. In other words, it can answer three kinds of hypotheses:

1: Are points with similar values (birds with similar personality) close to each other?

In this case is p-value<0.05 and Moran.I$observed will be positive number

2: Are points with similar values more distant from each other? (like chess-board pattern, where neighbours have opposite values)

In this case is also p-value<0.05 but Moran.I$observed will be negative number

3: There is random pattern in data (no spatial correlation)

In this case p-value>0.05

Computation:

library(ape)
# matrix of all distances...
my.dists <- as.matrix(dist(cbind(my.data$x_coor, my.data$y_coor)))
# ...which is inversed...
my.dists.inv <- 1/my.dists
# ...and their diagonals set to "0"
diag(my.dists.inv) <- 0

# than inserted into Moran.I with tested variable
Moran.I(my.data$aggression, my.dists.inv)

Result: Moran's I revealed a positive spatial correlation between points

Many thanks to Andy W

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.