Fitting model with error on independent variable This is the second part of a question started here. However, as this touches a different problem inside the same overall issue I decided do separate it into two questions.
I've made a series of measures of two variables, named $x$ and $y$. Let's assume that there is a function that describe the relationship between $x$ and $y$ of the form $y = a + bx + cx^2$. The actual function is, I think, not very important, but it will be a polynomial relationship (and a Bijective function).
As I measured both the dependent ($y$) and independent ($x$) variables, I also have an estimate of my error in this measurements. Suffice to say that this error is not the same to all points.
Now, usually, given some measures of an dependent variable with associated error I would do a fitting that take that into account, either by computing some weight to each point proportional to the inverse of the error or by using this error as the standard deviation for a normal distribution of each point (see the approach taken on R package FME to the error provided by the user). However, I'm not sure how to do it with both error's on the independent and dependent variable.
I've played with a couple of ideas, but I'm not sure what is correct. A simple idea as consider that each point $i$ has an error that is $e_i = \sqrt{(e_{x_i})^2 + (e_{y_i})^2 }$ where $e_{x_i}$ is the error of point $i$ on the independent variable and $e_{y_i}$ the error on the dependent variable.  Another idea consider the "areas of the point" and computes $e_i = e_{x_i}e_{y_i}$. Additionally, I can also "ignore" the error in the independent variable and generate a new dataset where, for each original point $i$ I randomly create new points from an normal distribution with mean equal $x_i$ and standard deviation $e_{x_i}$, with all having the same value of $y_i$ and a new weight proportional to the inverse of $e_{y_i}$. However, wouldn't this affect my model comparisons discussed on the linked question (AIC)?
ADDED AFTER COMMENTS FROM @Roland :
Deming regression looks like the proper way of dealing with this problem. However, as far as I can understand, the R package deming as 3 methods to solve this. The first, a generalized Deming regression, can take the error estimate in each point for each variable in the option xstd and ystd. This method is, however, sensitive to outliers. The authors of the package suggest the Passing-Bablock regression method for robust regression. However, as far as I can understand, this method can not receive the estimated error for each point...
 A: Several points.
If the residuals are not homoscedastic, you may be better off transforming the data into a form that can have homoscedastic residuals after fitting a model.
If you then want to see what the bias is, plot the residuals not with respect to the x-axis values but as ranked x-values, first, second third... Why? Regression for least error in y, when the x-data is randomized has strong tendency toward omitted variable bias. Ranking the x-axis residuals removes the independent variable bias that had been produced by ignoring that randomness during regression. You can then fit a line to those x-ranked residuals to see the slope and intercept of linear bias introduced by regressing in y-alone. Note that, to begin with, if instead of using ranked x-values, we had used the x-values themselves, there would have been zero for slope and intercept for a regressed line to those residuals, and all we would have shown is that we had, indeed, found the least error in y solution.
Next, there are circumstances in which Passing-Bablok can be used to remove bias. Here is one. Suppose the fit equation is of the form $f(x_1,x_2)=k x_1^{a1} x_2^{a2}$ with no significant intercept. Take the fit equation evaluated as $\ln f(x_i)$ and plot it against $\ln y_i$ using a Passings-Bablock regression. Note that Passing-Bablock is Theil-Sen regression with a correction for slope by discarding those two-point possible slopes that are negative before finding the median slope of the remaining set of all possible two-point slopes, with another procedure for intercept. Thus, Passing-Bablok regression does not work when the slope of the fit line is negative. Passing-Bablok appears to be either asymptotically correct or very close to that for positive slopes, but works best when the x and y values are on the same scale. In the case of omitted variable bias of $y_i\approx f(x_1,x_2)$, the Passing-Bablok linear fit will have a slope and intercept that are generally significantly different from 1 and 0 respectively. In that case, use those values to correct the regressed function's parameter values.
Finally, when that is done, one can produce new residuals. Those new residuals will be slightly larger than they were before because one now has a best relationship between x and y, not a least error in y result. However, the omitted variable bias seen as a linear non-zero slope and intercept of a line fitted to residuals plotted with ranked x-values will now be gone.
