Re: [R] Mahalanobis distance

From: Joris Meys <jorismeys_at_gmail.com>
Date: Wed, 23 Jun 2010 02:53:34 +0200

Say X is your data matrix with the variable, then you could do :  X <- matrix(rnorm(2100),300,7)
 S <- var(X)
 dist <- as.dist(

     apply(X,1,function(i){
         mahalanobis(X,i,S)
         }
     )

 )

Cheers
Joris

On Tue, Jun 22, 2010 at 11:41 PM, yoo hoo <freesuccess2001_at_yahoo.com> wrote:
> I am a new R user. i have a question about Mahalanobis distance.actually i have 300 rows and 7 columns. columns are different measurements, 300 rows are genes. since genes can
> classify into 4 categories. i used dist() with euclidean distance and cmdscale to do MDS plot. but find out Mahalanobis distance may be
> better. how do i use Mahalanobis() to generate similar dist object which i can use MDS plot? second question is if should i calculate mean for
> every categories for every measurement first and do 4*4 distance matrix, or i should calculate pairwise distance first and then find category
> means since i only care about relative position of 4 categories in MDS
> plot. Thank you very much.
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>

-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys_at_Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

______________________________________________
R-help_at_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.
Received on Wed 23 Jun 2010 - 00:57:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jun 2010 - 03:40:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive