Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Added goodness of fit fields to LsqFitResult #59
This is certainly not the most elegant way I did it but it works. I compared the goodness of fit results with the results Matlab spits out and I got the same values for sse and rmse but I had differences for r-squared and adj-r-squared at the third decimal place which I can't explain.
The parameters you are calculating are only statistically valid for linear regressions.
FWIW, I don't think baking this into LsqFit is necessary and/or a good idea anymore. Given that the coefficient of determination is not the same thing between a linear vs. nonlinear regression, I think this is something that should be left up to the user. At the very least, I think a "lazy" calculation would be better (ie a function call to calculate the coefficient) as not all users will want or need this.
I implemented this for myself with a simple:
rsquared = cor(data,model(t,fit.param))^2
which is correct for a linear regression (and simpler IIRC than the changes here).
I don't think we should allow users to calculate r2 easily, since it's non invalid under non-linearity in coefficients. The remaining changes are now in master some way or the other (or were already there at the time up the last update). Thanks for the work anyway @MLackner, it's appreciated that people interact and contribute. You're more than welcome to tackle any of the remaning issues with this package, contribute examples or just use the software if it helps you do your work.
Nonetheless, I'm closing this PR in favor of existing commits that have been merged into master already.