For data x=[123]x=⎡⎣⎢123⎤⎦⎥ and y=[453]y=⎡⎣⎢453⎤⎦⎥, fit a linear model y=ax+b+εy=ax+b+ε using the formula ˆβ=(XTX)−1XTYβ^=(XTX)−1XTY.
This exercise should be really simple, but I have some doubts about my reasoning.
Let Yi=β0+β1Xi+εYi=β0+β1Xi+ε describe the i-th sample. The matrix of regressors is X=[111123]X=[111213].
Therefore (XTX)−1=[14663]−1=[731112](XTX)−1=[14663]−1=[731112] and XTY=[1223]XTY=[1223].
The product of the matrix multiplication is:
ˆβ=(XTX)−1XTY=[731112]⋅[1223]=[4018.5]β^=(XTX)−1XTY=[731112]⋅[1223]=[4018.5]
Thus β0=b=40β0=b=40 and β1=a=18.5, meaning that the final linear model would be:
y=18.5x+40+ε.
Hover, this seems unlikely, because graph of such line would be way above the given points. Am I making a mistake in my calculations? If so, where my understanding is incorrect?