Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing attributes to other fit methods #81

Merged
merged 3 commits into from
Jan 5, 2014
Merged

Conversation

omdv
Copy link

@omdv omdv commented Jan 4, 2014

Greetings!

I started using LMFIT for my own project, where I switch between different fitting methods often and compare goodness of fit using reduced chisquared and Rsquared. I have discovered that all methods except least squares don't have defined redchi and residuals attributes. It was even pointed out on stackoverflow: http://stackoverflow.com/questions/17465701/attribute-error-from-minimizer-object-returned-from-scipy-optimize-minimize-fu

Hence the following changes were made to lbfgsb(), fmin() and scalar_minimize():

  • Residual attribute added to the remaining methods. It is based on calling __residual() with optimized parameters
  • Chisqr calculation is based on residuals
  • Redchi added
  • leastsq method is not changed

I tested this version with my project and haven't seen any issues. It also passed all available tests.
Please let me know if you have any questions or concerns.

Cheers

@newville
Copy link
Member

newville commented Jan 5, 2014

Thanks! I agree having chisqr and redchi would be nice for scalar minimizers. I'll merge this, but then alter it to use (as I think one of your earlier versions did) Minimizer.penalty() -- the scalar minimizing functions allow the objective function to return a single number. For your use case (and, I expect the most common), this would be exactly "chi-square". But it doesn't have to be that. Still, providing a redchi as if the users objective function returned either chi-square or an ndarray to minimize in the the least-squares sense is perfectly reasonable.

newville added a commit that referenced this pull request Jan 5, 2014
Added missing attributes to other fit methods
@newville newville merged commit fba1f84 into lmfit:master Jan 5, 2014
@EnboYang
Copy link

Is there add "R square" to fit report?
https://en.wikipedia.org/wiki/Coefficient_of_determination

@newville
Copy link
Member

@EnboYang This PR was merged almost a year ago. If you are requesting a further change to this code, you're too late. If you're asking a question about a new feature, you're in the wrong place.

Please don't mix questions with closed PRs -- the conversations are too hard to follow and find. Use the lmfit-py mailing list https://groups.google.com/forum/#!forum/lmfit-py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants