Calculation of residuals: Opposite of common calculation method #986
Replies: 5 comments 1 reply
-
@Timothy-J-Warner I have no preference for But, I would say that we should probably be internally consistent in the code, docstrings, and external documentation. And, as you say, l I don't have a preference for whether code or doc is changed. |
Beta Was this translation helpful? Give feedback.
-
The reason I say it is more "common" is when I do I quick search, (data - model) most commonly comes up but I didn't find a textbook reference etc. to confirm. I can create a PR to change the documentation or code but I am unsure if it will cause issues in other locations. For example I noticed the difference in residuals using ModelResult.plot and ModelResult.plot_residuals. Taking a quick look I think ModelResult.plot_residuals also defines (model - data)
while ModelResult.plot appears to use ModelResult.plot_residuals rather than defining residuals again. |
Beta Was this translation helpful? Give feedback.
-
@Timothy-J-Warner I think the goal should be consistency. And I think it would be fine to change the sign in the code. I have no preference. |
Beta Was this translation helpful? Give feedback.
-
How do you suggest that I do a PR for this change (I would be my first pull request to a large open source project). |
Beta Was this translation helpful? Give feedback.
-
@Timothy-J-Warner Make a fork into your own account, work there and push your work to your fork (probably doing When you are happy with the results, submit a Pull Request from there. I think there are probably good GitHub tutorials. |
Beta Was this translation helpful? Give feedback.
-
I noticed that the calculations of residuals have the opposite sign of what I expected based on the typical calculation method for residuals.
Commonly residuals are calculated:
but LMfit calculates:
Is there a specific reason the residuals are calculated this way? I know it doesn't affect squares and is an easy fix to reverse the sign but I wanted to know if there was reason for this definition. The reason I ask this is that I was confused about results I was receiving using LMfit (reversed sign for residuals) until I checked the source code and found the definition of residuals below:
Beta Was this translation helpful? Give feedback.
All reactions