Take errors into account for a data fit

  • Context: Undergrad 
  • Thread starter Thread starter kelly0303
  • Start date Start date
  • Tags Tags
    Data Errors Fit
Click For Summary

Discussion Overview

The discussion revolves around how to properly account for error bars associated with a dependent variable in data fitting, particularly in the context of nonlinear models. Participants explore methods for incorporating these errors into the fitting process to ensure that the parameter uncertainties are accurately reflected.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant inquires about the meaning of "almost identical" errors and suggests that understanding the effect on amplitude is crucial for the proposed fitting treatment.
  • Another participant describes their dataset, noting that the measurements are counts from an experiment at different energies, with errors derived from Poisson statistics.
  • A participant shares their experience with various fitting methods, including linear least squares, Poisson regression, and nonlinear least squares, and emphasizes the importance of the software used for fitting.
  • It is suggested that many software packages can report errors for model predictions and parameters, and that the Hessian matrix can be utilized for estimating these errors if writing custom code.
  • References to specific software packages like Python's lmfit and R's nls are made, indicating their potential usefulness for the fitting process.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the best method to account for errors in the fitting process, and multiple approaches are being discussed. There is uncertainty regarding the implications of the error treatment on the fitting results.

Contextual Notes

Limitations include the need for further clarification on the dataset and the specific nature of the nonlinear model being used. The discussion also highlights the potential complexity of error propagation in nonlinear fits.

kelly0303
Messages
573
Reaction score
33
Hello! I have some data in which the dependent variable ##y## has, for each data point, an error bar associated with it ##\delta y##. The errors are almost identical for each datapoint, so doing a weighted fit in terms of the errors would not change the results significantly. How can I take the errors into account properly, such that the error bars are reflected in the error on the parameters of the fit? I though initially to have 3 fits for the actual data points, for the upper and for the lower points of the error bars, but I am not sure that would give me what I need, as the function is highly nonlinear and this kind of fit would just influence the overall amplitude, not the other (more important) parameters. Thank you!

<Mentor - moved to statistics forum >
 
Last edited by a moderator:
Physics news on Phys.org
Could please you define what you mean by 'the errors are almost identical'? Which makes me wonder about your view of the effect on amplitude of your proposed treatment. It would help our statisticians if you elaborated on your dataset as well.

Thanks.
 
jim mcnamara said:
Could please you define what you mean by 'the errors are almost identical'? Which makes me wonder about your view of the effect on amplitude of your proposed treatment. It would help our statisticians if you elaborated on your dataset as well.

Thanks.
Thank you for your reply! The measurements are some counts produced in an experiment at different energies. The counts are, for each energy, somewhere between 100,000 (for background) and 300,000 (for signals). The error is Poisson i.e. square root of the number of counts.
 
Listed roughly in order of difficulty of estimating errors, I have fit count data using linear least squares (sometimes with a square root transformation), Poisson regression, and non-linear least squares to physical models.

From what you wrote I'm assuming you are asking about the last case and you have a physical model that is nonlinear in its parameters.

What software are you using to perform the fit? Because a short answer is that many packages (R, Matlab, Python) are capable of reporting errors for the model predictions and model parameters. The values required to estimate these errors are often calculated as part of the same iterative process as the fit.

If you are writing your own code to do it, you may be able to make use of an asymptotic approximation using the Hessian matrix (second derivatives) of a log likelihood. Briefly, a fit routine typically estimates both the parameters and the variance-covariance matrix related to the Hessian from which, along with the independent variable data, error estimates may be obtained.

See this article I found after a quick search: nonlinear least squares. Especially pages 5-10.

If you aren't reinventing the wheel for educational purposes, Python has the lmfit package that I'd probably use if I were doing it. R has an equivalent package called nls(?) I think, but I haven't used it.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
Replies
28
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 26 ·
Replies
26
Views
3K
  • · Replies 8 ·
Replies
8
Views
7K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K