Re: [R] vectorization of a loop for mahalanobis distance calculation

2008-10-07 Thread Frank Hedler
Dear all,we just realized something. Sarah's distance function - indeed - calculates mahalanobis distance very well. However, it uses the observed variance-covariance matrix by default. What we actually need (sorry for not stating it clearly in to be able to specify which variance-covariance matrix

Re: [R] vectorization of a loop for mahalanobis distance calculation

2008-10-07 Thread Sarah Goslee
Hi Frank, If the way distance() calculates the Mahalanobis distance meets your needs other than the covariance specification, you can tweak that _very_ easily. If you use fix(distance) at the command line, you can edit the source. change the first line to: function (x, method = "euclidean", icov)

Re: [R] vectorization of a loop for mahalanobis distance calculation

2008-10-07 Thread Sarah Goslee
distance() from the ecodist package will calculate Mahalanobis distances. Sarah -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http:

[R] vectorization of a loop for mahalanobis distance calculation

2008-10-07 Thread Frank Hedler
Dear all, We have a data frame x with n people as rows and k variables as columns. Now, for each person (i.e., each row) we want to calculate a distance between him/her and EACH other person in x. In other words, we want to create a n x n matrix with distances (with zeros in the diagonal). Howeve