Other linear fitting than least squares

In summary, Dale is analysing some data and he is getting a line that best fits the data, but he is getting black lines with a lower least-squares value.
  • #1
Felipe Lincoln
Gold Member
99
11
I'm analysing some data and my task is to get a line that best fits the data, using least square I'm getting these dashed curves (red and blue) with low correlation factors. Is there another method that takes into consideration the amount of data placed into the direction of a line?
graph.png
 

Attachments

  • graph.png
    graph.png
    22.3 KB · Views: 560
Physics news on Phys.org
  • #2
It seems like you must be doing something wrong with your least-squares fit. Can you calculate the least-squares value for the red, blue, and black lines? It looks lower for the black line.
 
  • Like
Likes FactChecker
  • #3
Those red and blue lines don’t look right. I think there must be something wrong in your code
 
  • #4
the black line is just the identity y=x. The red and blue I got through my data.
I used the scipy.stats.linregress, can't see what's wrong but I'll take a look again
 
  • #5
Oh there was some data hiding beyond my axis limits. Sorry for this mistake, I'll fix it and post the result.
graph2.png
 

Attachments

  • graph2.png
    graph2.png
    12.6 KB · Views: 474
  • #6
So if you do a leverage plot that one datapoint will probably have a huge leverage. I would check that point and see if there is some error. Like maybe a typo when copying the data.
 
  • Like
Likes FactChecker
  • #7
Aha! So the standard least squared regression is doing a good job on the entire data set. But you should consider that the data visible in your first post looks like it is following a different rule than the entire set. If you can see the reason for that, you may want to analyse the data in sections that make more sense.
 
  • Like
Likes Felipe Lincoln
  • #8
Why do you think fitting a straight line to that data (however it is done) would be a good idea?
 
  • #9
Stephen Tashi said:
Why do you think fitting a straight line to that data (however it is done) would be a good idea?
It is an experimental data that is expected to have a linear correspondence.
I just removed the zeroes data and this is what I got now. Thank you all
graph.png
 

Attachments

  • graph.png
    graph.png
    18.7 KB · Views: 432
  • #10
Felipe Lincoln said:
I just removed the zeroes data and this is what I got now.
Do you have any experimental justification for that?
 
  • #11
Dale said:
Do you have any experimental justification for that?
Yes sir. The zeroes was generate by my code to represent experiments that failed and resulted in no data.
 
  • #12
Felipe Lincoln said:
Yes sir. The zeroes was generate by my code to represent experiments that failed and resulted in no data.
That is an excellent reason!

It is never a good idea to throw away data just because it makes your fit better, but if a data point is bad for some specific reason then throwing it out is acceptable.
 
  • Like
Likes Felipe Lincoln
  • #13
FYI, you may want to also look into that data point with the high Rphenix. It looks like it has a very high leverage and it may have some other problem.
 
  • Like
Likes FactChecker
  • #14
Right! The next step in our research is to analyse what was the experiment conditions that bring some points a bit far from the expected. Thanks for your attention Dale!
 
  • Like
Likes Dale

1. What is the purpose of using linear fitting other than least squares?

The purpose of using other linear fitting methods is to better fit a line to a set of data points that do not have a linear relationship. Least squares is a popular method but it may not always be the most accurate or appropriate for certain datasets.

2. What are some examples of other linear fitting methods?

Some examples of other linear fitting methods include the method of least absolute deviations, robust regression, orthogonal distance regression, and total least squares. These methods take into account different aspects of the data and may be more suitable for certain types of datasets.

3. How do these methods compare to least squares in terms of accuracy?

The accuracy of these methods can vary depending on the dataset and the underlying assumptions. In some cases, these methods may provide a more accurate fit than least squares, while in other cases they may not perform as well. It is important to assess the suitability of each method for a specific dataset.

4. Are there any disadvantages to using linear fitting other than least squares?

One potential disadvantage is that these methods may be more computationally intensive than least squares. They may also require more specialized knowledge and skills to implement and interpret the results. Additionally, some of these methods may have stricter assumptions that need to be met in order to obtain accurate results.

5. How do I determine which linear fitting method to use for my data?

The best method to use will depend on the specific characteristics of your data and the goals of your analysis. It is important to consider the underlying assumptions and limitations of each method, as well as the performance on your dataset. It may also be helpful to consult with a statistician or conduct further research on the various methods to determine the most appropriate one for your data.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
486
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
23
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
24
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
26
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
900
Back
Top