Re: [R] adding a method to the dist function

About this list Date view Thread view Subject view Author view Attachment view

From: Prof Brian Ripley (ripley@stats.ox.ac.uk)
Date: Mon 03 May 2004 - 21:05:21 EST


Message-id: <Pine.LNX.4.44.0405031202490.25987-100000@gannet.stats>

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@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

______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:07 EST