| Summary: | regression: wrong calculation of chi^2 reduced for fits | ||
|---|---|---|---|
| Product: | [Applications] LabPlot2 | Reporter: | Uwe Stöhr <uwestoehr> |
| Component: | backend | Assignee: | Stefan Gerlach <stefan.gerlach> |
| Status: | RESOLVED NOT A BUG | ||
| Severity: | grave | CC: | stefan.gerlach, uwestoehr |
| Priority: | NOR | ||
| Version First Reported In: | latest | ||
| Target Milestone: | --- | ||
| Platform: | Microsoft Windows | ||
| OS: | Microsoft Windows | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | example plot | ||
Here is the fit result of MagicPlot for comparison: LAST FIT Data Points Number: 35 Fitted Curves Number: 1 Parameters Number: 2 Degrees of Freedom (DoF): 33 Data Total Sum of Squares (TSS): 6.4226e8 Weighting: Standard Error (w = 1 / stdErr^2) DATA INTERVALS From To 0 1200 RESULTS Iterations: 5 Convergence: 1.8829e-13 Residual Sum of Squares (RSS, χ^2): 64.737 Reduced RSS: 1.9617 Residual Standard Deviation: 1.4006 Coefficient of Determination R^2: 1 Adjusted R^2: 1 FITTED CURVES Custom Curve Fit curve A=557.4639±22.049 B=468.3198±26.5106 y(x) = A*exp(-B/x) FITTED PARAMETERS Parameter Fit curve A Fit curve B Value 557.4639 468.3198 Std. Dev. 22.049 26.5106 FIT FORMULA WITH VALUES y(x) = 557.4639*exp(-468.3198/x) FIT FORMULA WITH VARIABLES y(x) = A*exp(-B/x) A = 557.4639 B = 468.3198 s_A = 22.049 s_B = 26.5106 CORRELATION MATRIX Parameter Fit curve A Fit curve B Fit curve A 1 0.9415 Fit curve B 0.9415 1 It looks like you did an unweighted fit. In this case the calculated chi^2 is correct. To do a weighted fit, you have to select "Instrumental" for y-Weight and the error column in the dock widget. There were two related bugs that are fixed now: 1. Weighted fitting was possible only for data from spreadsheet (not from a curve) 2. weighted fitting failed when the given error was zero I will release a Windows package for 2.7.0rc3 tomorrow on https://theorie.physik.uni-konstanz.de/gerlach/labplot/. Let me know if that works for you. > To do a weighted fit, you have to select "Instrumental" for
> y-Weight and the error column in the dock widget.
I cannot find this setting. What I did was:
- setting the third column in the spreadsheet as y-error
- in the advanced fitting dialog I checked "use given data errors"
So why does this then not result in a weighted fit?
I sent you a private mail with the testing result of LP 2.7.RC3: I cannot test properly because of crashes. OK, now I found it. To get a weighted fit one has to set that LP should really take the given error column. It would be very useful if this would be the default if there is an error column. Moreover the setting section "Weight" is by default collapsed and thus very hard to find. it should be unfolded by default like all other sections in the fit dialog. |
Created attachment 120756 [details] example plot The main task for me with LabPlot is curve fitting but in version 2.6 there is a bug leading to wrong calculations of the chi^2: - open the attached plot - recalculate the fit and look at the results: LP tells me I have a chi^2 reduced of 441. This is obviously wrong since the fit is not that bad. It looks like it is around 2. And indeed, when performing the same fit with another program I get a Chi^2 reduced of 1.9617.