# More Than You Ever Wanted to Know About Calibrations, Part 2 – Curve Fits and Weighting

1 Aug 2022In the previous blog post I talked about the different types of calibrations in the sense of how to set up the standards. Once you’ve determined that, the next step is how to mathematically go from a response reading to a concentration. Be warned, this blog will be a bit math heavy.

## Linear Fit

Most detectors have a linear relationship between sample concentration and the detector response, where a difference in concentration should yield a proportional change in response, with that proportion being the response factor. This means that the most basic way to generate a calibration curve is to analyze standards at different concentrations and draw a linear line of best fit through them. If you remember your high school algebra this is the y = mx + b equation that you probably spent a lot of time working with. In the linear equation y is the dependent variable (i.e., the variable that responds to the input), x is the independent variable (the input), m is the slope (how much the dependent variable changes based on change from the independent variable), and b is the y intercept, or offset from 0. When talking about calibration curves, y is the instrument response (or response ratio of compound/IS for internal standard methods), x is the concentration (or concentration ratio of compound/IS for internal standard methods), m is the response factor, and b is a measure of the baseline response at a concentration of 0.

You might be thinking that the x and y variables should be switched. After all, the intent of the calibration is to turn a response into a concentration, so you might think of the response as the input or independent variable. However, since the concentration of the sample determines the response, the concentration is really the independent variable, so to convert a response to a concentration the equation you really need is (y – b)/m = x.

How do you determine the slope and intercept? The equations for it are shown in Figure 1, but Excel or any modern analytical software will be able to do this much more quickly and accurately, so there’s no need to bust out the old pencil and TI- 84 calculator for this.

Figure 1 – Equations for determining slope and intercept for linear equations.

An average response factor (RF) equation is a special case of a linear fit. In it you determine the slope by averaging the response factor (response/concentration or response ratio/concentration ratio) for each calibration point. This gives you a linear fit with the intercept set to 0.

## Quadratic Fit

Many methods allow for the use of quadratic fits as well as linear fits or average RF calibrations. In an ideal situation, your linear detector should give a linear response for all compounds. However, some compounds are more troublesome than others. In assays that have dozens of compounds, sometimes the ideal isn’t possible and compromises have to be made.

A quadratic curve is given by the equation y = ax^{2} + bx + c, where a is the quadratic term, b is the linear term, and c is the y intercept. While linear fits give you two equations to solve independently, quadratic fits give three equations that have to be solved together, shown in Figure 2.

Figure 2 – Equations for determining quadratic fit

Once again, software will save the day and there’s no need to solve these by hand unless you really love solving equations. Once you have your quadratic regression, if you want to solve for x or the concentration then you’ll have to use the quadratic formula, which will probably never be forgotten by anyone who took an algebra class. For those of you who did manage to forget though, it’s shown in Figure 3.

Figure 3 – Quadratic formula

While many methods allow for the use of quadratic fits, it’s important to be careful and use them sparingly. Methods with large compound lists may have troublesome compounds that can’t be optimized to respond linearly, but if compounds that normally are linear start to show quadratic fits then it’s likely an indication of some analytical issue. Using a quadratic fit in those cases may give you an acceptable calibration per the method requirements but would be masking an underlying issue that will cause problems down the road.

## Curve Weighting

The equations given above are for equal or unweighted curves. The curve fit assumes equal absolute variance for each point, or that the errors in response are independent of the value of x. You can see from the equations that the curve fits are based largely on sums of the x and y values, or sums of them multiplied together in various ways. This means that larger numbers have a larger impact on the curve fit. For a very narrow calibration curve this may not matter, but when you span several orders of magnitude the absolute variance on the high end of the curve will be significantly more than the low end, meaning that the variance of y does depend on the value of x. This potentially leads to poor results at the lower end of the curve.

To counteract this, weighted regressions can be used. In weighted fits the amount that each calibration point contributes to the curve is based on the precision of that point. If multiple measurements are taken for each calibration point the precision of each point could be calculated and each point weighted independently. In practice though, this isn’t very practical, so most software allows the use of some standard weightings, usually 1/x or 1/x^{2}, to be applied to all points. The general form for the weighted linear fit equations is shown in Figure 4, where w_{i} is the weighting.

Figure 4 – Weighted linear fit calibration equations

As shown in my TO-15A calibration blog, the use of weighting means the curve no longer minimizes the absolute error. This means you may get more error in the top end of the curve while improving the low end, reducing the overall relative error in the calibration. A later blog will talk more about curve accuracy and acceptance criteria and why weighted fits can be important.

Note that while most chromatography software allows for weighted fits, Excel only does unweighted fits, though you can find some templates online that will help you with it if you don’t want to manually calculate them yourself.

Average RF calibrations are actually a type of weighted linear fit, so they are not as dominated by the high end of the curve as unweighted calibrations. They are also forced through zero as a default, which is a good stopping point and segue into my next blog. If you are still awake and eager to learn about calibrations, the next blog will cover the pros and cons of forcing your curve through zero.

View all of the posts in the "More Than You Ever Wanted to Know About Calibrations" series.