Calculating Line of Best Fit: Least Squares Method

  • Thread starter EngNoob
  • Start date
  • Tags
    Fit Line
In summary, the person is trying to find the inverse matrix of a 2x2 matrix, which is found in a textbook. They are stuck and need help. They have data that corresponds to the matrix, however they don't know how to find the answer to the equation for the inverse matrix. The person provides a step by step guide on how to calculate the inverse matrix using the design matrix product.
  • #1
EngNoob
38
0
I need to calculate a line of best fit, using...

The least square fit method.

I am upto the stage where i have created my matrix 2 x 2, and then i have invesed the matrix 2 x 2 and then got a fraction and a [2x2] matrix.

Now i am stuck.

The textbook has the inverse matrix, and the matrix of co-ordinates used to create the origional matrix, and i don't get how the anser is established

Any help most appreciated
 
Physics news on Phys.org
  • #2
EngNoob said:
I need to calculate a line of best fit, using...

The least square fit method.

I am upto the stage where i have created my matrix 2 x 2, and then i have invesed the matrix 2 x 2 and then got a fraction and a [2x2] matrix.

Now i am stuck.

The textbook has the inverse matrix, and the matrix of co-ordinates used to create the origional matrix, and i don't get how the anser is established

Any help most appreciated

This tells us nothing about what you have actually done. What points is the line supposed to fit? What matrices did you construct? What formula are you using?
 
  • #3
Ok, this was a very stupidly produced post, so sorry.

Here is the data i have.

I have a matrix, which is m x t,

[1][0]
[1][1]
[1][3]
[1][4]

and have another matrix b

[0]
[1]
[2]
[5]

Using the least square fit process, i need to establish an ATA Matrix or

[ sum m ] [ sum t ]
[ sum t ] [ sum t ^2 ]

I have been given the answer to this as

[4][8]
[8][26]

What i don't understand, is how does the 26 get their?

The forumula says sum t^2, or 8 x 8, which is 64. 8 doesn't go into 26 either, so i am at a loss what i am doing wrong?

Maybe i am using the wrong formula?

The det(ATA) is 40, which would indicate the 26 should be there, however, can't figure out from the data where 26 comes from?

Any help appreciated, and sorry for the weak post...
 
  • #4
That last element is sum(t^2), ie, the sum of squares.

Perform the design matrix product ([itex]A^{T}A[/itex]) yourself, and I think you'll see.
 
  • #5
Spot on, i have the answer now, i was been a little thick, (t) t meaning transpose right, thanks...
 

FAQ: Calculating Line of Best Fit: Least Squares Method

1. How do I calculate the line of best fit using the least squares method?

To calculate the line of best fit, you will need to find the slope (m) and y-intercept (b) of the line that minimizes the sum of the squared distances between the line and all of the data points. This can be done using the formula: m = (n * Σxy - Σx * Σy) / (n * Σx^2 - (Σx)^2) and b = (Σy - m * Σx) / n, where n is the number of data points and Σ represents the sum of the values. Once you have these values, you can plug them into the equation y = mx + b to find the equation of the line of best fit.

2. What is the purpose of calculating the line of best fit using the least squares method?

The purpose of calculating the line of best fit is to find the relationship between two variables and make predictions based on this relationship. The least squares method helps to find the most accurate line that represents the data and can be used to make predictions about future values.

3. How do I know if the line of best fit is a good fit for my data?

One way to determine if the line of best fit is a good fit for your data is by calculating the coefficient of determination (r^2). This value represents the proportion of the variation in the data that is explained by the line of best fit. The closer the r^2 value is to 1, the better the line of best fit represents the data.

4. Can the least squares method be used for non-linear data?

No, the least squares method is only applicable for linear data. If the relationship between the variables is non-linear, other methods such as polynomial regression or exponential regression should be used to find the best fit line.

5. What is the difference between the line of best fit and the regression line?

The line of best fit and the regression line both represent the relationship between two variables, but the line of best fit is specifically calculated using the least squares method while the regression line can be calculated using other methods such as polynomial regression or exponential regression. The regression line is also used to make predictions, while the line of best fit is primarily used to visualize the relationship between the variables.

Similar threads

Back
Top