[R] correlation between two 2D point patterns?
Bernardo Rangel Tura
tura at centroin.com.br
Sun Aug 30 11:46:08 CEST 2009
On Sun, 2009-08-30 at 07:51 +0100, William Simpson wrote:
> Suppose I have two sets of (x,y) points like this:
> I would like to measure how similar the two sets of points are.
> Something like a correlation coefficient, where 0 means the two
> patterns are unrelated, and 1 means they are identical. And in
> addition I'd like to be able to assign a p-value to the calculated
> gives two numbers instead of one.
> gives a correlation matrix
> I have looked a little at spatial statistics. I have seen methods
> that, for each point, search in some neighbourhood around it and then
> compute the correlation as a function of search radius. That is not
> what I am looking for. I would like a single number that summarises
> the strength of the relationship between the two patterns.
> I will do procrustes on the two point sets first, so that if A is just
> a rotated, translated, scaled, reflected version of B the two patterns
> will superimpose and the statistic I'm looking for will say there is
> perfect correspondence.
> Thanks very much for any help in finding such a statistic and
> calculating it using R.
If your 2 points set is similar I expect your Euclidean distance is 0,
so I suggest this script:
dist<-sqrt((x1-x2)^2+(y1-y2)^2) # Euclidean distance
t.test(dist) # test for mean equal 0
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
More information about the R-help