Unless you want to do this millions of times, efficiecy is probably not
a big issue here, but simplicity always pays off.

I'm presuming you are dealing with a single classification setup.

Let f (n x 1) be a *factor* defining the classes
Let X (n x p) be the data matrix.

Then the steps I would use to find the between and within SSP matrices,
'by hand' are as follows:

Tot <- scale(X, scale = FALSE)          # sweep out the grand means
Res <- resid(aov(X ~ f))                # sweep out the class means

WSS <- crossprod(Res)                   # within SSP matrix
BSS <- crossprod(Tot - Res)             # between SSP matrix

 


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, 10 July 2007 9:25 AM
To: [email protected]
Subject: [R] Within matrix

Hi all,

I am working on cluster, I am trying to evaluate a within and between 
matrix. Is there any facility for that ? I did my own function, but I 
am not a programmer, so I am affraid I am not really able to programme 
efficiant and fast function...

Thanks

Christophe

----------------------------------------------------------------
Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre

______________________________________________
[email protected] 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.

______________________________________________
[email protected] 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.

Reply via email to