# Getting error in fit

I was wondering if anyone had run into the problem of trying to estimate errors in their signal processing on spectroscopic data. I know that many people use spectroscopic techniques to estimate concentrations of different materials, but I would like to know how accurate these measurements can be (i.e. I would like to get an output something like "species A is 20% +-1% of the sample given"). Further, I would like to know how to deal with very extreme cases, where several different types of materials are present, and may have observables which fall directly on top of each other.

A simple example may be the following:

You can see there are two species being fit to the data. If the areas are then transformed by calculation into percentages, (i.e. the sample taken is 48% B, 52% A) how can we be sure of this and how accurate is the fit? I know this will be dependent on the accuracy of the estimate of the positions of these peaks that are (perhaps) given by the user, so I am interested in a method that takes a known error in the parameters (say +-15 on the x axis for error in the peak center position, +-10 error in the width of the peak, etc.).

I suspect that the errors will become large when the observables overlap (i.e. the peak centers for two fitting functions are the same).

In addition, it is possible that these spectra have a large background, which may also have error, affecting all of the other species and their errors. I am not certain if this background would be treated differently than all of the other species, or if it could be treated within the same algorithm as all of the other species.

To illustrate my point further, here is an image of a spectroscopic measurement of several different materials:

On the top in red is the raw data given by optical absorption (the measured data), while the black is a calculated background, and the blue is a calculated sum of all of the species including the background.

On the bottom, the calculated background is subtracted (blue and red lines now DO NOT include the calculated background), while the several different colored lines below are each individual species being summed up to create the blue line.

These are the calculated measurements I am interested in estimating the error in.

As you can see, the error is enormously large in this example for most of the calculated measurements. Each species may or may not have several 'peaks' associated with it, which can be illustrated by the bolded yellow calculated line. In addition, you can see that several of the calculated peak centers fall around the same place, so this will likely reduce the certainty that the measurements are correct even if the calculated line falls directly upon the raw data.

I have calculated the mean squared displacement as a quick estimate of how good the fit is, but I know that this doesn't do anything to address any larger concerns of the actual calculated measurement uncertainty. The most I have really done in statistics is standard deviation and calculations dealing with several measurements, but this is quite different, since it deals with how sure you can be with only one measurement, not seeing differences in multiple measurements. Is there a way of using confidence intervals and confidence levels on non independent and identically distributed random variables? (Again, I am very new to statistics and have never taken a course on it, so I apologize if this is elementary or trivial)

• Is there a functional characterization of each component? For example, the first picture seems to be the mixture of two Gaussians. The second picture appears to have more complex components. – Peter K. May 7 '13 at 20:04
• Each line is a Voigt function (convolution of Lorentzian and Gaussian functions) or exponential. The background is created from two Voigt (mostly Gaussian character) functions and two exponential functions, whereas all of the other functions are Voigts of mostly Lorentzian character – chase May 8 '13 at 2:22

Well, without knowing the specifics of your algorithm, I assume that you basically have multiple functions (e.g. Gaussian or Lorentzian peaks, each with position and FWHM parameters, additionally maybe some polynomials for backgrounds etc.) and you sum them all up into one big "fit function" that you hand over to an optimization algorithm that jiggles the parameters around until you found a good fit in the sense of non-linear least squares.

What you can do then is computing the asymptotic standard errors. For this, you have to (most likely numerically) compute the Jacobi Matrix of your fit function (matrix of partial derivatives for each parameter (columns) at each measurement point (rows)). From this you can compute the variance-covariance matrix and then compute the errors for each parameter. This is an approach very often found in curve fitting software. In fact, there is a quite comprehensive explanation here at OriginLabs (see the section on Parameter Standard Errors). Also a more detailed overview can be found here at arxiv.

Other methods are discussed in this paper. They certainly are appropriate and maybe even mandatory in some cases, but I find them a bit too complicated for most "real world" applications.

If I were you, I would go with the asymptotic standard errors for a first start and see, if they fit the needs. It is an easy to implement strategy that is, as already said, also widely found in software packages.