Re: [R] correlation between two 2D point patterns?
Thanks Chuck. Interesting suggestion. Thanks to everyone for the help. Bill On Sun, Aug 30, 2009 at 4:59 PM, Charles C. Berrycbe...@tajo.ucsd.edu wrote: Bill, prod( cancor( A,B )$cor ) perhaps? Note that this accounts for linear transformations. HTH, Chuck On Sun, 30 Aug 2009, William Simpson wrote: Suppose I have two sets of (x,y) points like this: x1-runif(n=10) y1-runif(n=10) A-cbind(x1,y1) x2-runif(n=10) y2-runif(n=10) B-cbind(x2,y2) 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 statistic. cor(x1,x2) cor(y1,y2) gives two numbers instead of one. cor(A,B) 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. Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] correlation between two 2D point patterns?
Suppose I have two sets of (x,y) points like this: x1-runif(n=10) y1-runif(n=10) A-cbind(x1,y1) x2-runif(n=10) y2-runif(n=10) B-cbind(x2,y2) 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 statistic. cor(x1,x2) cor(y1,y2) gives two numbers instead of one. cor(A,B) 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. Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] correlation between two 2D point patterns?
On Sun, 2009-08-30 at 07:51 +0100, William Simpson wrote: Suppose I have two sets of (x,y) points like this: x1-runif(n=10) y1-runif(n=10) A-cbind(x1,y1) x2-runif(n=10) y2-runif(n=10) B-cbind(x2,y2) 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 statistic. cor(x1,x2) cor(y1,y2) gives two numbers instead of one. cor(A,B) 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. Bill Hi Bill, 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 Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] correlation between two 2D point patterns?
On Sun, Aug 30, 2009 at 10:46 AM, Bernardo Rangel Turat...@centroin.com.br wrote: On Sun, 2009-08-30 at 07:51 +0100, William Simpson wrote: Suppose I have two sets of (x,y) points like this: x1-runif(n=10) y1-runif(n=10) A-cbind(x1,y1) x2-runif(n=10) y2-runif(n=10) B-cbind(x2,y2) 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 statistic. cor(x1,x2) cor(y1,y2) gives two numbers instead of one. cor(A,B) 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. Bill Hi Bill, 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 I'm not sure what you'd do for two sets of points - compute the sum of all the distances from points in set 1 to the nearest point in set 2? That'll be zero for identical patterns, but also zero if you have superimposed points in set1 but not in set 2. If rotation and scale and translation are of interest to you then what you are doing is shape analysis. There's a package for that[1]. http://www.maths.nott.ac.uk/personal/ild/shapes/ Barry [1] Not quite as catchy as 'there's an app for that' __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] correlation between two 2D point patterns?
Bill, prod( cancor( A,B )$cor ) perhaps? Note that this accounts for linear transformations. HTH, Chuck On Sun, 30 Aug 2009, William Simpson wrote: Suppose I have two sets of (x,y) points like this: x1-runif(n=10) y1-runif(n=10) A-cbind(x1,y1) x2-runif(n=10) y2-runif(n=10) B-cbind(x2,y2) 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 statistic. cor(x1,x2) cor(y1,y2) gives two numbers instead of one. cor(A,B) 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. Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.