Skip to content

Avoiding the mean

2 messages · Christian Hennig, Thomas Lumley

#
Dear list,

what is the fastest way to compute a multivariate mean and cov-matrix? I
presume that the mean is computed in cov, so it may be a waste of time to
compute the mean first and then a second time inside of cov. Is it faster
to use cov.wt, which gives cov-matrix and center?
And: If mean and cov should be computed on a part of the data, is it faster 
to use cov.wt with some weights zero, or should cov (or cov.wt) be computed
on a subset?

Best,
Christian
#
On Fri, 22 Feb 2002, Christian Hennig wrote:

            
The answer to this question is *always* "try it and see" (Rprof or
system.time).  It probably isn't faster, but the answer will depend on the
number of rows and columns in your data and possibly on other factors.
It's unusual for computing the mean or covariance to take enough time to
worry about.
Probably using a subset would be faster, but again, you can easily try it
and see.


	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._