[R] Mahalanobis distances

Christian Hennig chrish at stats.ucl.ac.uk
Fri Jun 24 18:02:53 CEST 2005


On Fri, 24 Jun 2005, Spencer Graves wrote:

(...)
> 	  The key is computing your own generalized inverse and using that with
> "inverted=TRUE".
(...)

One method to do this is function solvecov in package fpc.

Christian

>
> 	  spencer graves
>
> Karen Kotschy wrote:
> > Dear R community
> >
> > Have just recently got back into R after a long break and have been amazed at
> > how much it has grown, and how active the list is! Thank you so much to all
> > those who contribute to this amazing project.
> >
> > My question:
> > I am trying to calculate Mahalanobis distances for a matrix called "fgmatrix"
> >
> >
> >>dim(fgmatrix)
> >
> > [1] 76 15
> >
> >
> >>fg.cov <- cov.wt(fgmatrix)
> >>mahalanobis(fgmatrix, center = fg.cov$center, cov = fg.cov$cov)
> >
> >
> > Then I get an error message "Covariance matrix is apparently singular"
> >
> > What does this mean? I can't see anything strange about the covariance matrix,
> > and am not getting anywhere with the help files.
> >
> >
> >>dim(fg.cov$cov)
> >
> > [1] 15 15
> >
> >>length(fg.cov$center)
> >
> > [1] 15
> >
> >
> > Thanks
>
> --
> Spencer Graves, PhD
> Senior Development Engineer
> PDF Solutions, Inc.
> 333 West San Carlos Street Suite 700
> San Jose, CA 95110, USA
>
> spencer.graves at pdf.com
> www.pdf.com <http://www.pdf.com>
> Tel:  408-938-4420
> Fax: 408-280-7915
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

*** NEW ADDRESS! ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chrish at stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche




More information about the R-help mailing list