pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Oneway Anova from a covariance/cross-product matrix?


From: John Darrington
Subject: Oneway Anova from a covariance/cross-product matrix?
Date: Mon, 5 Jul 2010 15:13:03 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

Now that we've got a working, reasonably robust and generic covariance
matrix routine, I wanted to rework the oneway anova command to use it.
If we could do this it would seem to be more elegant and we could get
rid of some hard to maintain code. 

However, although I'm told this is possible, I can't work out how to
do it.  Let's consider a simple dataset with two groups (that would
normally call for a T-TEST but for the sake of simplicity I've chosen
only two groups for this ANOVA example). 

x  group
========
1   A
2   A
3   A
2   B
4   B
6   B

Solving this conventionally is straightforward.

The grand total is 18 and the grand mean is 3.
The total sum of squares SST is 16.

For group A, the total is 6 and the mean is 2.
The sum of squares for A is 2.

For group B, the total is 12 and the mean 4.
The sum of squares for B is 8.

Thus the total sum of squares within groups is 2 + 8 = 10.

And we can see this using the ONEWAY command:

#================#==============#==#===========#====#============#
#                #Sum of Squares|df|Mean Square|  F |Significance#
#=#==============#==============#==#===========#====#============#
#x|Between Groups#          6,00| 1|       6,00|2,40|         ,20#
# |Within Groups #         10,00| 4|       2,50|    |            #
# |Total         #         16,00| 5|           |    |            #
#=#==============#==============#==#===========#====#============#


Now trying to solve this using a matrix solution.  First we allocate
a bit vector for the group variable:

x   g1   g2
===========
1   0    1
2   0    1
3   0    1
2   1    0
4   1    0
6   1    0



but we drop one column (because that's what the theory tells us to do).
Now we have:

x   g1
======
1   0 
2   0 
3   0 
2   1 
4   1 
6   1 




The cross-product matrix for this data is:

      x    g1
x   16.0  3.0
g1   3.0  1.5


It's clear that the  total sum of squares can be picked straight from
the first element.  But how do I get the Within Groups sum of squares?
This information just doesn't seem to be there.

Other software can do this, so it must be possible.  I can't figure
out how.  What's the trick?


-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]