adding a method to the dist function
On Mon, 3 May 2004, Giampiero Salvi wrote:
On Mon, 3 May 2004, Prof Brian Ripley wrote:
On Mon, 3 May 2004, Giampiero Salvi wrote:
Hi all, I'd like to add the Bhattacharyya method to the dist function. What is the best way to do this? I'm using R 1.9.0 and I was looking for the code that defines the already existing distances, but I didn't manage. As far as I understand, dist is defined in mva that is part of the stats package now, but where is the code?
In src/library/stats/src/distance.c Where else did you think the C source code for the stats package would be but src/library/stats/src?
Sorry, I was looking in the installation directory that of course didn't have a src dir...
You will need to add your own function, and BTW, I don't think `the Bhattacharyya method' is appropriate for dist, as it is defined for distributions, not data items. It's even defined that way in your own paper
I also had the same doubt. My intension was to interpret the data matrix as composed by vectors of means and covariances, but I did suspect that this would generate some confusion. Do you have any suggestions on where this method better belongs?
dist() compares pairs of rows in the x matrix. How can they have `means and covariances'? -- you have a sample of size one from each of two populations. It seems that (Gaussian) Bhattacharyya is more like mahalanobis().
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595