pspp-dev
[Top][All Lists]
Advanced

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

Re: Oneway Anova from a covariance/cross-product matrix?


From: John Darrington
Subject: Re: Oneway Anova from a covariance/cross-product matrix?
Date: Sat, 24 Jul 2010 07:56:00 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

It doesn't seem to work properly.   The following code:

{
  gsl_matrix *m = gsl_matrix_alloc (2, 2);

  gsl_matrix_set (m, 0, 0, 1.5);
  gsl_matrix_set (m, 1, 0, 3);
  gsl_matrix_set (m, 0, 1, 3);
  gsl_matrix_set (m, 1, 1, 16);


#define X 0

  printf ("Before:\n");
  gsl_matrix_fprintf (stdout, m, "%g ");

#if X
  gsl_matrix_swap_rows (m, 0, 1);
  gsl_matrix_swap_columns (m, 0, 1);
#endif


#if X
  int x = reg_sweep (m, 0);
#else
  int x = reg_sweep (m, 1);
#endif


#if X
  gsl_matrix_swap_columns (m, 0, 1);
  gsl_matrix_swap_rows (m, 0, 1);
#endif

  printf ("After: %d\n", x);
  gsl_matrix_fprintf (stdout, m, "%g ");
}

should give the same results regardless of the value of X .
However, I found that if X == 0
I see:

Before:
1.5 
3 
3 
16 
After: 0
-0.666667 
2 
3 
10 

Which is correct (I think).  However if X == 1 I get:

Before:
1.5 
3 
3 
16 
After: 0
1.5 
3 
3 
0 

which is not.

J'



On Tue, Jul 20, 2010 at 06:37:13PM -0400, Jason Stover wrote:
     On Thu, Jul 08, 2010 at 03:19:14PM +0000, John Darrington wrote:
     > However I think this is going to become an unmitigated nuisance.
     > We can't always be sure that the dependent variable will be the last
     > row/column  and I see that there is code in the fill_covariance function
     > in regression.q which rearranges the matrix to satisfy this condition.
     > 
     > I suggest that instead, we change reg_sweep so that it accepts an integer
     > which is the index of the row/column of the dependent variable....
     
     I just made this change.
     
     > On Wed, Jul 07, 2010 at 11:25:32AM -0400, Jason Stover wrote:
     >      On Tue, Jul 06, 2010 at 07:09:05PM +0000, John Darrington wrote:
     >      > So what exactly do we pass to reg_sweep ?
     >      > 
     >      > Passing M doesn't seem to help.  If we need to use g or x then 
that 
     >      > requires access to the raw data.  I understood that anova could 
be calculated 
     >      > from M alone.
     >      
     >      Almost: reg_sweep expects the final column and row to contain the 
values related to
     >      the dependent variable. So it should work with
     >      
     >          g1            x
     >      g1  1.5           3.0
     >      x   3.0           16.0
     >       
     >      Also, that matrix doesn't contain information related to the
     >      intercept, or "grand mean," meaning you would need to either include
     >      such a column in your covariance matrix, or call
     >      post_sweep_computations.

-- 
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]