I have a bunch of data points $(x, y)$, and I know that they fit well to a model of the form $y = a + bx + c x^2$, with $a \approx 0.01, \ b \approx 1\ \textrm{and}\ c \lesssim 0.1$. I'd like to fit the actual values of the parameters $a, b, c$. This far, reasonably standard linear regression. However, the twist is that the values $y$ are known exactly (essentially by definition, see the longer explanation in the end), while the $x$ -values have errors, which are not equal between points (heteroscedasticity is the word, I believe?). The errors originate from analog measurement noise, so the simple model is that they are independent and normally distributed. They're not equal because they're actually a ratio of the raw measurements, and by error propagation the error in the ratio depends on the values of the points themselves. The error magnitudes vary by quite a lot, so I'd like to do a weighted fit.
First, let me point out that I'm a theoretical physicist by education, which means that my last encounter with serious statistics was back in undergraduate courses, so I may be missing something obvious here.
So my questions are:
- is there some well known method to do the fit? Googling seems to lead to total least squares and generalized least squares, which deal with the case of errors in both dependent and independent variables, and I'd imagine my case would warrant some simplification vs. the fully general case
- my current idea to do this easily is to just use the fact that I know the approximate parameters, so I can trade the error in $x$ for an error in $y$ via error propagation/implicit function theorem (i.e. there is some $y$ which corresponds exactly to the actual unknown $x$, and I can estimate the difference from the known $y$ via the implicit function theorem). Since $b \approx 1$, this actually just makes the $y$ error approximately the same as the $x$ error. I could also iterate, i.e. use the initial fit to get a better estimate of the errors for a second round, and so on. However, the fact that I haven't seen this mentioned anywhere makes me suspect I'd be doing something horribly wrong?
Explanation of the underlying problem, in case there's an XY-problem here:
I'm measuring the gain of an analog circuit as a function of a control voltage applied, more specifically the digital control value used to set it via a DAC. I measure the actual gain $g$ as a function of the DAC value $n$ for a number of values $n$. So $n$ is exact, and $g$ has an error that I can estimate, since I know the noise floor of the system. Using that, I want to build a calibration function $n(g)$, which gives me the $n$ I need to set in order to achieve some desired gain $g$. Both from observation and theory, I know that the fit is almost linear, but with a small $g^2$ -term (due to Early voltage in a transistor, and the exact function is a actually a rational function, but within measurement accuracy I can't tell it apart from the $O(g^2)$ approximation).
So the natural thing, at least to me, is to tabulate the points as $(g, n)$ and then fit the polynomial, but this leads to the situation that the errors are in the independent variable. If this were a linear fit, I could just fit $(n, g)$ and then invert the function, but since I'm now fitting a polynomial, the inverse function will not itself be a polynomial, so I'd have to do a non-linear fit. Or I could invert approximately as a series, but that's piling one approximation on top of another, which I'd rather avoid.
A similar question that does not solve my problem:
Here's a similar question, but as the recommendation there is to use Deming regression, which however seems to give the same result as no errors at all when applied to the case where there is no error in the dependent variable.