avehtari / ROS-Examples

Regression and other stories R examples
https://avehtari.github.io/ROS-Examples/
325 stars 256 forks source link

[p. 104] Error in Formula for Slope of Simple Regression. #62

Closed jgaeb closed 3 years ago

jgaeb commented 3 years ago

Hello! There seems to be an error in the formula for the slope of a simple regression on page 104. What's written in Eq. (8.3) is

\hat b = \frac {\sum_{i = 1}^n (x_i - \bar x) y_i} {\sum_{i = 1}^n (x_i - \bar x)^2}.

If I'm not mistaken, I think you want

\hat b = \frac {\sum_{i = 1}^n (x_i - \bar x) (y_i - \bar y)} {\sum_{i = 1}^n (x_i - \bar x)^2},

unless there is an assumption I'm just somehow not seeing that the y_is are already centered or something like that. Thanks!

jgaeb commented 3 years ago

My mistake—since sum_{i = 1}^n (x_i - \bar x) = 0, the two formulas are equivalent. Closing the issue! Sorry for any confusion.