Menu

#103 Function to compute fit residuals

open
nobody
None
5
2019-05-07
2019-05-07
No

I would like to be able to add a column of residuals to my table after (or along with) finding a fit to my data. That is, I'd like a column whose values are

y_residual = y_data - y_fit ,

where y_fit = y(x_data): the fitting function (with optimized parameters) applied to that row's x value.

I can obviously do this by hand, but it's tedious and I worry about typos in copying the function and adjusting it to use column syntax, or typos and rounding error when copying its parameters. I've looked into writing a Python script to do the job for me, but I haven't yet figured out how to get Python to refer to existing tables and graphs and fits. (Is there some Python function that would list all available/active user objects? Or any easy way to identify "the second fit for the active graph"? It doesn't help that I'm not especially experienced in Python.) But honestly, it would be lovely (and handy for my students) if this were just built in somehow. I'm imagining it being availble as a button in the "Custom Output" page of the Fit Wizard, maybe close to the Parameters Table and Covariance Matrix buttons.

This is a capability that I remember using in Origin back when I was a student in the 90s (I believe there was a "Paste Residuals to Data Window..." button in the fit wizard that just added a column named "Residuals" to the same table that the data fame from). It's very helpful when assessing how well a model fits your data. (One nice discussion of that can be found here: http://www.physics.hmc.edu/analysis/fitting.php.) I'd like to think that this would be a relatively straightforward feature to program, at least to someone who knew the code. (I've pulled a copy, but there's a lot going on in there: I'd need to spend a long time just figuring out the basic structures and functions to use, and I expect I'd reinvent wheels and overlook pitfalls along the way.)

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.