[R] Within matrix

Bill.Venables at csiro.au Bill.Venables at csiro.au
Tue Jul 10 02:43:55 CEST 2007


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:Bill.Venables at csiro.au
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
cgenolin at u-paris10.fr
Sent: Tuesday, 10 July 2007 9:25 AM
To: r-help at stat.math.ethz.ch
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

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list