# Linear Regressions vs Algebra & Averaging in Solving for a Constant

I'm current taking AP Physics, and in both of the labs performed so far (Snell's Law/Refraction and Galileo's Inclined Plane), I have been trying to calculate some constant from a linear relationship between two variables, with some form of $$y = mx$$, where $$y$$ and $$x$$ are two variables measured in the lab, while $$m$$ is the desired quantity.

Both labs used a linear regression, which seems to make sense in this situation. However, when taking chemistry last year, we never used regression lines, and always averaged our data for $$x$$ and $$y$$, before using the relationship equation to solve for the unknown.

Which technique usually gives more accurate answers? Why is that so?

• Just for clarity, precisely what do you mean by "averaged our data for x and y before using the relationship equation to solve for the unknown"? – Samuel Weir Sep 26 at 23:31

# Problem Statement

Suppose that you have a set of $$N$$ values from measured data $$(y_j,x_j)$$ that are known from first principles to follow the function $$y = mx$$. The points in the data set may each have their own uncertainty values (errors) $$\delta x_j$$ and $$\delta y_j$$

You have two approaches to obtain $$m$$ from this data set.

## Method 1 - Point-by-Point Averages

• Use each $$y_j, x_j$$ pair to obtain $$m_j$$ by algebra from the fundamental equation.
• Determine the average $$\langle m \rangle = \sum m_j/N$$ and standard uncertainty $$S = \ldots$$ of the $$N$$ values.

## Method 2 - Linear Regression

• Use a linear regression, curve-fitting routine (e.g. a Levenberg-Marquardt method) to obtain $$\langle m \rangle$$ and $$\delta m$$, the standard uncertainty of the regression fit parameter.

When should you apply Method 1 or Method 2?

You should always prefer to apply Method 2 over Method 1 for a few reasons, fundamental and practical.

• Method 2 includes an additional data point (0,0) that cannot be contained in any way by Method 1. Without going in to the mathematical proof, the result is that the confidence you can have in the results for the values of $$\langle m \rangle$$ and $$\delta m$$ is increased using Method 2 over Method 1 for the same number of data points $$N$$.

• Robust, first principle, analytical approaches have been developed in both methods that allow you to include the uncertainties $$\delta y_j$$ as weighting parameters during the regression fitting. However here again, the approach in Method 2 allows you to lock down the point at $$(0, 0)$$ to be infinitely accurate (having no experimental uncertainty) or to be a measured value in its own right. By example, you cannot include a MEASURED data point at $$x_0 = 0$$, $$y_0 = 0.10 \pm 0.01$$ in the weighted fitting routines for Method 1 but you can include it in Method 2.

• Analytical approaches have been developed to include uncertainties $$\delta x_j$$ as weighting parameters during the regression fitting for Method 2. They are essentially non-existent or cumbersome to apply in Method 1.

• Tools that allow you to do a basic (non-weighted) linear regression fitting of a data set are widespread and freely/inexpensively available. They exist even on smart phones and smart hand-held calculators. Tools that allow you to do weighted linear regression are equally widespread and free/inexpensive on desktop computers.

# Summary

In all cases, Method 2 will give answers that are more robust. In most cases, the tools to apply Method 2 are as readily available and as easy to use (if not easier to use) than those for Method 1. In some cases (data points with individual uncertainties), the tools available will be those used to apply Method 2.

# Tangential Insights

In the US, first year college chemistry undergraduate labs are often taught with the presumption that the students in them may not understand math much beyond algebra and/or have no aptitude for using computer tools beyond what is to be done using a hand-held calculator. The use of Method 1 is not inherently wrong in and of itself. What is wrong is propagating the view that Method 1 is an acceptable approach in all cases. The failure can be as simple as the instructor not making a statement that simple averaging is only a first approximation (linear regression is the truly robust approach) or as blatantly disrespectful as stating explicitly or implicitly that linear regression is not worth the effort involved (since simple averaging gives about the same value anyway).

Normally, a linear regression assumes no uncertainty in the independent variable (e.g., x). If this assumption is valid and the relationship is actually linear, a linear regression drives a line through the data such that the errors in the dependent variable normally distribute themselves around the regression line. From a statistical point of view, this is a better way to estimate the slope of the line that you are fitting than taking some kind of straight average, especially if you have a lot of data points (e.g., 30 or more).

• Uh, doesn't regression assume error is normally distributed, not 0? – Kyle Kanos Sep 27 at 23:19
• @KyleKanos, linear regression assumes no error in the independent variable with normally distributed error in the dependent variable. If there is error in the independent variable, the situation gets more complicated, and it's been some time since I ran into this problem, so I don't remember the details. – David White Sep 28 at 0:20
• Okay yes, it's $y\sim mx+b+\varepsilon$, so $y$ has the normal error. – Kyle Kanos Sep 28 at 12:36