# Least squares regression

1. Oct 21, 2015

### stats_student

1. The problem statement, all variables and given/known data
note a linear regression model with the response variable Y=(Y1..Yn) on a predictor variable X=(X1..Xn). the least squares estimates of the intercept and slope a(hat) and B(hat) are the values that minimize the function: (see attached image)

and the problem reads on further -

further predicted values equal y(hat)(x)=a(hat)+b(hat)x (note y(hat) is meant to be read as a function of x)

i have been asked to find y(hat)(Xbar), where X(bar) is the average of the Xi's. (note y(hat) is meant to be read as a function of Xbar).

i'm not sure where to start with this question. advice as to whether i'm on the right track is all i need for now.

so i was thinking that i could use the fact that

a(hat) = Y(bar)-B(hat)X(bar) and B(hat) = (sum) (Xi-X(bar))(Yi-Y(bar)) /(sum) (Xi-X(bar))^2

but i'm not exactly sure how to solve for y(hat)X(bar) -(yhat as a function of Xbar)

should i be trying to get a equation with only a(hat) , b(hat) , and Xbar?

Thanks for the help - apologies for poor notation

#### Attached Files:

• ###### Snapshot.jpg
File size:
6.7 KB
Views:
61
2. Oct 21, 2015

### Ray Vickson

If you have set up and solved the least-squares equations (so that you know the parameters $\hat{a}, \hat{b}$ in terms of the $\{x_i, y_i\}$, you can just substitute $x = \bar{x}$ into the equation $\hat{y} = \hat{a} + \hat{b} x$, and carry out algebraic simplification.

BTW: it is easy to employ good notation---just use LaTeX. To see how I did it, just right-click on an expression and to to the menu item to 'display math as tex commands'. This site has a brief LaTeX tutorial on the use of LaTeX, but I cannot say exactly where/how to find it; others may know.

3. Oct 22, 2015

### stats_student

so if i do this should i get
\hat{y} =Y(bar)?

4. Oct 22, 2015

### stats_student

y(hat)(Xbar) = Y(bar)? still hopeless at notation :(

5. Oct 22, 2015

### stats_student

or should i get,
Y(bar) = a(hat) +b(hat)X(bar)

6. Oct 22, 2015

### Ray Vickson

You need to tell the system "LateX starts here" ... and "Latex ends here", with your mathematical expressions in between.

For displayed equations use

[t ex] ...your expressions ... [/t ex]

with no spaces between the 't' and the 'ex', and not in a red-colored font (which I used just for emphasis). Doing that on your expression above gives
$$\bar{Y} = \hat{a} + \hat{b} \bar{x}$$
Note that we write \bar{Y}, not Y(bar), and we write \hat{a}, not a(hat). Some people prefer the look of \overline{...} instead of \bar{...}, and using that instead gives
$$\overline{Y} = \hat{a} + \hat{b} \overline{x}$$

For in-line equations or expressions, use

# # ... expression... # #

with no space between the two #s at the start and at the end, and not in a red font. Doing that with your expression above gives $\bar{Y} = \hat{a} + \hat{b} \bar{x}$, as wanted.

Anyway, you cannot just wrote that $\bar{Y} = \hat{a} + \hat{b} \bar{x}$, because the right-hand-side is $Y_{\text{fitted}}(\bar{x})$, but how do you know that $Y_{\text{fitted}}(\bar{x}) = \bar{Y}$? Can you even be sure it is true?

Last edited: Oct 22, 2015
7. Oct 22, 2015

### stats_student

should i get y(Xbar) = a(hat)+b(hat)X(bar)

8. Oct 22, 2015

### Ray Vickson

Yes, but that is not the end of the story. You ought to be able to simplify it a lot, using either the explicit expressions for $\hat{a}$ and $\hat{b}$, or by exploiting the fact that $\hat{a}, \hat{b}$ satisfy some particular equations obtained by minimization of the total squared error.

9. Oct 22, 2015

### stats_student

ahhh... so after doing some algebra i get yhat(Xbar) = Y(bar)

10. Oct 22, 2015

### stats_student

let me try in notation $$\hat{y}(\bar{x})=\bar{Y}$$

11. Oct 22, 2015

### Ray Vickson

Yes, exactly.