[R] mahalanobis distance

Rolf Turner r.turner at auckland.ac.nz
Mon Jul 20 22:44:06 CEST 2009


On 21/07/2009, at 7:57 AM, Michael Knudsen wrote:

> On Mon, Jul 20, 2009 at 9:37 PM, ekinakoglu<ekin at ims.metu.edu.tr>  
> wrote:
>
>> Could you please help me with a pseudo matrix of 4x4
>> that is gonna work with mahalanobis?

	Please speak English.  ``gonna'' is not appropriate
	for written communication.

> Hmmm ... I have been trying some different matrices myself now, but I
> keep getting the same error. Even if det(S) is very far from zero.
> Maybe I just don't get the point of the mahalanobis() function in R.
> It looks quite weird to me :-(

Huh?

Try:

 > set.seed(42)
 > X <- matrix(rnorm(100),25,4)
 > S <- var(X)
 > x <- rnorm(4)
 > mahalanobis(x,rep(1,4),S)
[1] 6.082543

	cheers,

		Rolf Turner


######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}




More information about the R-help mailing list