[Date Index]
[Thread Index]
[Author Index]
Re: Computing a covariance matrix
*To*: mathgroup at smc.vnet.net
*Subject*: [mg73653] Re: Computing a covariance matrix
*From*: Paul Abbott <paul at physics.uwa.edu.au>
*Date*: Sat, 24 Feb 2007 02:08:30 -0500 (EST)
*Organization*: The University of Western Australia
*References*: <erme5t$i8b$1@smc.vnet.net>
In article <erme5t$i8b$1 at smc.vnet.net>,
eleutheroskaiwraios at googlemail.com wrote:
> I was looking on how to compute a covariance matrix given a set of
> measurements and I was utterly frustrated having to jump from one
> discussion group to another and harvesting the web through maths
> websites having to cope with all sorts of notations.
I would have thought that you would find the required
derivation/computation in _many_ places.
> I managed to find a nice example on how to derive a covariance matrix and decided to
> share it with you :)
>
> Go to:
>
>
> "How the stat packages compute a correlation matrix"
>
> http://luna.cas.usf.edu/~mbrannic/files/pmet/vcv2.htm
>
> It should be quite easy to understand how it is done. It even shows
> you how to standardise the matrix at the end.
>
> NOTE: this is cross-posted at:
>
> sci.math
> sci.stat.math
> comp.soft-sys.math.mathematica
> alt.math.undergrad
As far as I can see, you have only posted this message to MathGroup
(comp.soft-sys.math.mathematica), not to the other groups.
Also, I'm not sure what this has to do with Mathematica specificially? I
note that CovarianceMatrix, which computes VCV in your notation, is in
the package
<< Statistics`MultiDescriptiveStatistics`
Here is a direct Mathematica implementation of your example:
X = {{1, 2, 3}, {2, 3, 4}, {1, 2, 3}, {5, 4, 3}, {4, 4, 4}}
x = Transpose[X] - Mean[X]
SSCP = x . Transpose[x]
VCV = SSCP/(Length[X] - 1)
s = Sqrt[Variance /@ x]
correlationmatrix = VCV/Outer[Times, s, s]
Cheers,
Paul
_______________________________________________________________________
Paul Abbott Phone: 61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul
Prev by Date:
**Re: Question: Plots via command-line using front-end fonts?**
Next by Date:
**Re: Fw: 2**
Previous by thread:
**Computing a covariance matrix**
Next by thread:
**Re: Computing a covariance matrix**
| |