7
$\begingroup$

this may be a silly question, but still:

  • I've been told that the slope formula equals the rise/run ratio, like this:

$$ m = \frac{rise}{run} = \frac{y_2 - y_1}{x_2 - x_1} $$

in which rise equals detaY and run equals deltaX

  • however, I've also seen it using Pearson's correlation coefficient, such as in many posts here, like this one or this one :

$$ b = r_{x,y} \frac{\sigma_y}{\sigma_x} $$

  • Probably they're the same thing and I'm not able to see it... but, how are these two equations the same? I'd really want to understand this.
$\endgroup$
2
  • $\begingroup$ Hi Larissa. If you are still not aware of, Cross Validated is MathJax enabled; for a quick guide, check: Instructions on how to use LaTeX on CrossValidated. $\endgroup$ Sep 24 at 20:34
  • $\begingroup$ thank you for the link! and thanks @Tim for the answer and the edit, the post looks much nicer now! I'll work on the answer! $\endgroup$ Sep 24 at 23:52

2 Answers 2

11
$\begingroup$

For only two points they are the same.

The slope of simple linear regression is

$$ \hat \beta = \frac{\sum_i (x_i - \bar x) (y_i - \bar y)}{\sum_i (x_i - \bar x)^2} $$

that is the same form you mentioned in the second bullet. Notice that when we have two points, then things like $x_1 - \bar x$ can be written as

$$ x_1 - \frac{x_1 + x_2}{2} = \frac{x_1 - x_2}{2} $$

So we can re-write

$$ \require{cancel} \begin{align} \hat \beta &= \frac{\frac{x_1 - x_2}{2}\frac{y_1 - y_2}{2} + \frac{x_2 - x_1}{2} \frac{y_2 - y_1}{2}}{ \frac{x_1 - x_2}{2}\frac{x_1 - x_2}{2} + \frac{x_2 - x_1}{2}\frac{x_2 - x_1}{2} } \\ &= \frac{ (\frac{x_1y_1}{4} - \frac{x_1y_2}{4} - \frac{x_2y_1}{4} + \frac{x_2y_2}{4}) + (\frac{x_2y_2}{4} - \frac{x_2y_1}{4} - \frac{x_1y_2}{4} + \frac{x_1y_1}{4}) }{\cancel{2} \frac{x_1 - x_2}{\cancel 2}\frac{x_1 - x_2}{2}} \\ &= \frac{\frac{x_1 y_1 - x_1 y_2 - x_2 y_1 + x_2 y_2}{\cancel 2}}{ (x_1 - x_2)\frac{x_1 - x_2}{\cancel 2}} \\ &= \frac{\cancel{(x_1 - x_2)}( y_1 - y_2)}{\cancel{(x_1 - x_2)}(x_1 - x_2)} \\ &= \frac{y_1 - y_2}{x_1 - x_2} = \frac{y_2 - y_1}{x_2 - x_1} \end{align}$$

They must have been the same because the regression line calculated for two points needs to pass through them as there's no "noise". Linear regression is a linear model, so they need to be algebraically the same.

If you have more than two points, as Dave mentioned, you cannot use the rise/run formula anymore.

$\endgroup$
7
$\begingroup$

These are fairly unrelated concepts.

In the first equation, that is the slope of the line connecting two points.

In the second, you are finding a line that fits multiple points best (according to a particular and common definition of best). This line is called the ordinary least squares regression line. This is what is produced by “add trendline” in Excel. Unlike in the first case, your “trendline” might not hit any of the points.

The two will coincide if you have two points and fit a “trendline” to those points (aside from a technicality if the points have the same $x$- or $y$-coordinate), but I’d say that the similarities mostly end there.

$\endgroup$
2
  • $\begingroup$ huhhh, very interesting, thank you. If you don't mind, could you go over the part "The two will coincide if you have two points and fit a “trendline” to those points, but I’d say that the similarities mostly end there" ? @Dave $\endgroup$ Sep 24 at 16:37
  • $\begingroup$ What about it? The math works out that way. It might be a useful exercise to do the algebra. @LarissaCury $\endgroup$
    – Dave
    Sep 24 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.