1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Least squares regression

  1. Oct 21, 2015 #1
    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:

  2. jcsd
  3. Oct 21, 2015 #2

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    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.
  4. Oct 22, 2015 #3
    so if i do this should i get
    \hat{y} =Y(bar)?
  5. Oct 22, 2015 #4
    y(hat)(Xbar) = Y(bar)? still hopeless at notation :(
  6. Oct 22, 2015 #5
    or should i get,
    Y(bar) = a(hat) +b(hat)X(bar)
  7. Oct 22, 2015 #6

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    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
    [tex] \bar{Y} = \hat{a} + \hat{b} \bar{x} [/tex]
    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
    [tex] \overline{Y} = \hat{a} + \hat{b} \overline{x} [/tex]

    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
  8. Oct 22, 2015 #7
    should i get y(Xbar) = a(hat)+b(hat)X(bar)
  9. Oct 22, 2015 #8

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    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.
  10. Oct 22, 2015 #9
    ahhh... so after doing some algebra i get yhat(Xbar) = Y(bar)
  11. Oct 22, 2015 #10
    let me try in notation [tex] \hat{y}(\bar{x})=\bar{Y} [/tex]
  12. Oct 22, 2015 #11

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    Yes, exactly.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted