> "Simon, Steve, PhD" schrieb:
> 
> I just wrote an S-plus function that computes the statistical measures described in
> 
> 
> > corr.reg
> function(x, y)
> {
>         ey.x <- resid(lm(y ~ x))
>         ex.y <- resid(lm(x ~ y))
>         rde.y <- cor(abs(ex.y), abs(y - mean(y)))
>         rde.x <- cor(abs(ey.x), abs(x - mean(x)))
>         rde.y - rde.x
> }
> 
> Even if you don't use S-plus, you should be able to follow this. Note that the syntax
>  lm(y~x) fits a linear regression model with y as the dependent variable. The rest of
>  the syntax should be obvious.
> 
> I tried it with some random uniform variables as follows:
> 
> > x1 <- runif(50)
> > x2 <- runif(50)
> > y <- x1+x2
> > corr.reg(x1,y)
> [1] -0.7029148
> > corr.reg(x2,y)
> [1] -0.6784307
> > corr.reg(x1,x2)
> [1] -0.02448412

Hi Steve, 

 I wonder why the coefficents have so high absolute values; if I
 compute them, then in your case of corr.reg(x1,y) I get even with
 ideal data a maximum absolute value of ~0.5 .

 This value occurs, if in 

>         rde.y <- cor(abs(ex.y), abs(y - mean(y)))

 I have z-value variables as parameters as well as in

> > y <- x1+x2
> > corr.reg(x1,y)

The other aspects of your implementation seem to be correct.
Uhmm, btw, are x1 and x2 uncorrelated when created like this in
S-Plus? If not, the absolute rde-value should be smaller again.


Regards -

Gottfried

--
Gottfried Helms
Univ. Kassel.
.
.
=================================================================
Instructions for joining and leaving this list, remarks about the
problem of INAPPROPRIATE MESSAGES, and archives are available at:
.                  http://jse.stat.ncsu.edu/                    .
=================================================================

Reply via email to