pspp-dev
[Top][All Lists]

## Re: reg_sweep

 From: Jason Stover Subject: Re: reg_sweep Date: Wed, 25 Aug 2010 17:37:49 -0400 User-agent: Mutt/1.5.18 (2008-05-17)

```On Wed, Aug 25, 2010 at 02:43:07PM +0000, John Darrington wrote:

> 1. The comment says:
>   /*
>    LAST_COL is considered to be the final column in the augmented matrix,
>    that is, the column to the right of the '=' sign of the system.
>    */
>
>   If I understand the theory correct, this should read "to the LEFT of the =
> sign" ??

I was thinking of it this way:

Suppose A is an n by n matrix, x an n by 1 vector, and y an n by 1
vector. The values of A and y are known. reg_sweep solves the system

A x = y

for x. This is done by forming an augmented matrix

a_{11} a_{12} ... a_{1n} | y_1
a_{21} a_{22} ... a_{2n} | y_2
........................ | ..
a_{n1} a_{n2} ... a_{nn} | y_n

and using Gaussian elimination. I thought I had coded reg_sweep to
assume LAST_COL was the column corresponding to the vector y above,
which is on the right-hand side of Ax = y.

> 2. Results from my initial experiments suggest that:
>
>    a) In order to  do a factorial anova, we would need to run reg_sweep N
> times where
>       N is this number of factor variables.

No, it should only require one call of reg_sweep on the covariance matrix.
Unless there is more than one dependent variable, one call to reg_sweep
should suffice.

>    b) We need to add another variable to reg_sweep to tell it which variable
> we're currentl
>       interested in.

I don't understand what you mean by "which variable we're currently
interested in." Do you mean the dependent variable? Anyway, reg_sweep
is meant to be dumb: It just runs Gaussian elimination.

> 3. reg_sweep can't be used to calculate the intercept.

That is true. I did that to save space in what could become a very
large matrix. You can get the intercept by doing this:

intercept = (mean of dependent variable)
- sum_i (coefficient[i] * mean (explanatory variable[i]))

> Do we need to do some extra work on reg_sweep, or am I using it wrong?

It sounds like you are using it wrong, though there is a chance it
needs updating. I can help if you send some sample code.

-Jason

```