# Linear regression

1. Oct 26, 2012

### iVenky

I read about "Linear regression" and I want to make sure that what I read is right

Just tell if these equations are right-

Slope of line of regression for y on x is given by

$m=\frac{E(XY)-E(X)E(Y)}{E(X^{2})-[E(X)]^{2}} \\ m=\frac{Cov(XY)}{Var(X)} \\ m=\frac{ρσ_{x}σ_{y}}{σ_{x}^{2}} \\ m=\frac{ρσ_{y}}{σ_{x}} \\and\ the\ equation\ is \\y-\bar{y}= m (x-\bar{x})$

Similarly the slope of line of regression of x on y is given by

$\\ \\ m=\frac{ρσ_{x}}{σ_{y}} \\and\ the\ equation\ is \\x-\bar{x}= m (y-\bar{y})$

Just tell me if the above equations are right.

Thanks a lot

Last edited: Oct 26, 2012
2. Oct 27, 2012

### chiro

Hey iVenky and welcome to the forums.

Those look correct if you swap the x's and x_bar's with the y's and y_bar's. So think about y - y_bar = m(x - x_bar) instead.

Also, we usually we write B0 = y_bar - B1_hat*x_bar (this is obtained by setting x = 0 and solving for y) and B1_hat = m (the gradient).

3. Oct 27, 2012

### iVenky

I mean, you should swap
$x\ and\ \bar{x}\ with\ y\ and\ \bar{y}$ for finding out the line of regression for x on y (not y on x) right?

4. Oct 27, 2012

### chiro

No you need to swap both.

Recall that the definition of a straight line in two dimensions has one form which is y - y0 = m(x - x0) and this is something from high school geometry. In this definition (x,y) is a point on the line and (x0,y0) is a specific point on the line with m being the gradient.

5. Oct 27, 2012

### iVenky

Please note that I have written the equation for two cases

i) Y is a function of X and the equation is given by the one that you have written
ii) X is a function of Y. By which I mean I have taken the values of Y along the X axis and values of X along the Y axis. If that is the case you have to swap them.

See my question. I have written the equation for both cases. :)
Thanks a lot

6. Oct 27, 2012

### chiro

If you changing the axis then recall that in two dimensions m1*m2 = -1 where m2 is the gradient of the line perpendicular to that involving the gradient m1.

7. Oct 27, 2012

### iVenky

If I change the axis the slope won't be perpendicular to the one before. For eg: Y increases as X increases (slope is positive). This means that X increases as Y increases. (once again slope is positive and not negative)

8. Oct 27, 2012

### chiro

Ohh yes, sorry you are spot on.