[R] Pooled Covariance Matrix

From: Murray Jorgensen <maj_at_stats.waikato.ac.nz>
Date: Wed 20 Sep 2006 - 04:45:15 GMT


I am in a discriminant analysis situation with a frame containing several variables and a grouping factor, if you like:

set.seed(200906)
exampledf <- as.data.frame(matrix(rnorm(50,5,2),nrow=10,ncol=5))
exampledf$Group <- factor(rep(c(1,2,3),c(3,3,4))) exampledf

I'm sure there must be a simple way to get the within group pooled covariance matrix but I haven't found it yet.

I started thinking that one might begin by forming a frame with the same   dimensions but containing the group means. But then I found a thread from two years back called "Getting the groupmean for each person" which seemed to imply that doing this was a bit subtle even for ncol=1. Hence I will risk a question to the list.

Thanks for any help, Murray Jorgensen

-- 
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj@waikato.ac.nz                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    Home +64 7 825 0441    Mobile 021 1395 862

______________________________________________
R-help@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.
Received on Wed Sep 20 14:50:14 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 20 Sep 2006 - 07:30:05 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.