Questions about using matrices for finding best straight line by linear regression

In examples I have seen so far which show how to find a line which best fits a set of points, the equations are set out in a matrix form and so I am learning about matrices.
To simplify suppose we have thre points then the eqautions are
x1*m +c = y1
x2*m +c = y2
x3*m + c = y3
(m is the slope, c the offset)
in matrix form we can have

$\begin{bmatrix} x_1 & 1 \\ x_2 & 1 \\ x_3 & 1 \end{bmatrix} $ $\begin{bmatrix} m \\ c \end{bmatrix} $ = $\begin{bmatrix} y_1 \\ y_2 \\ y_3 \end{bmatrix} $ 

so say this is
X M = Y
Then to remove the X on the left side we need to multiply X by the inverse of X, and to do that we need X to be a square matrix. If X is n x 2 then we can multiply by a matrix D say which is 2 x n to give n x n.
In the examples I have seen D is chosen to be the transpose of X.

Question 1
Why use the transpose of X? couldn't we use any matrix within reason which is 2 x n?

Question 2
How does the whole think work anyhow considering that the measured points will not be exactly on the straight line so really we should write
x1*m +c = y1 + e1
x2*m +c = y2 + e2
x3*m + c = y3 + e3
where e is the error in y.
Is the assumption that if the errors were included in the calculation then they would average out to zero?

The same questions relate to finding the best circle for a set of measured points.

  • Mathe Mathe
    0

    I don't understsand the last question, about the circle. Could you expand on it perhaps?

    • If you want to find the best circle fit you can adopt the same approach- Maybe I shouldn't have mentioned the ciircles! If the measured point is x,y and the arc centre is a,b and the radius is r then (x - a)^2 + (y - b)^2 = r^2 By expanding you can get the same sort of matrix arrangement but more columns for X. But again in examples I have seen the transpose of X is used to mltiply X, and again the errors in measured values are ignored.

  • Kav10 Kav10
    +1

    Low bounty!

  • Maybe. The question seems to me like a simple one and it would take someone less than 5 minutes to read and less tha 5 minutes to answer. So that's $60 an hour. If I'm wrong I'll reconsider, but I'm not a mathemetician so my judgement is not good.

Answer

Answers can be viewed only if
  1. The questioner was satisfied and accepted the answer, or
  2. The answer was disputed, but the judge evaluated it as 100% correct.
View the answer
Amas Amas
171
  • Thank you Amas that's a very comprehensive answer in greater depth than I was expecting.

The answer is accepted.
Join Matchmaticians Affiliate Marketing Program to earn up to 50% commission on every question your affiliated users ask or answer.