# Formula for single linear regression for dataset that has uncertainties on both x and y

I'm going to teach classes on Physics Laboratory on First year of Bachelor studies. In most of the excercises during data analysis students will have to fit a line to measurements they have taken.

I need formulas that fit data to the model:

$$y_i = Ax_i + B + \epsilon_i$$

Where $\epsilon_i$ is error for point $i$.

Since in most cases they will have significant errors on both $x_i$ and $y_i$ I need to include: $\sigma_{x_i}$ and $\sigma_{y_i}$). But I have found only formulas that only include errors on $y_i$ by including weights:

$$w_i=\frac{1}{\sigma_{y_i}^2}$$

I would also like to have formulas for uncertainities on $A$ and $B$ that if needed take into account $\sigma_{x_i}$ and $\sigma_{y_i}$.

Any references to sources that discusses this problems would be also appreciated.

PS. While I would like to be able to use OLS for this --- it is not necessary, model just must be simple enough to be used (and understood) by first year students, and simple enough to be implemented in OOCalc on Excel sheed withhout using advanced stats functions.

PS II. I really checked most obvious sources for that formulas, so please be kind :)

• The generic term for this is Errors-in-variables models. The particular case you're considering looks like Deming regression. – onestop Feb 11 '12 at 13:44
• Deming regression is very nice, but as far as I understand it assumes that:Uncertainity rates are the same for each point, and I know there will be different in my setting. Also there is no mention of how to calculate errors of A i B. – jb. Feb 11 '12 at 14:52

I doubt errors-in-variables models can be fit in Excel (can Excel even fit weighted least squares? - which is the bare minimum you need). There is definitely no OLS solution other than hoping/assuming that the errors in the $y$s are sufficiently homogenous and that those in the $x$s are not particularly material and hence it is ok to do inference based conditionally on the observed $x$s.
From your question and the answer to @onestop's comment it sounds like you are confident a) that the $\sigma_{x_i}$ and $\sigma_{y_i}$ vary systematically and b) it is feasible to model this variation. If b) holds there will be a solution to your problem but it will pretty involved. I would question the need for a). Even allowing their to be error at all in the $x$s is a big step forward; why not assume for now that the variance of that error is constant (at least till you get evidence otherwise).
I would first have a go at Deming regression, assuming a constant variance for $x_i$ from measurement error. This should certainly be enough to go along with, and will be too much for Excel I am sure. The MethComp package in R can implement Deming regression.