# Re: Help: Weighted quadratic fitting under IDL?

• Subject: Re: Help: Weighted quadratic fitting under IDL?
• From: landsman(at)my-deja.com
• Date: Wed, 15 Mar 2000 10:41:21 GMT
• Newsgroups: comp.lang.idl-pvwave
• Organization: Deja.com - Before you buy.
• Xref: news.doit.wisc.edu comp.lang.idl-pvwave:18927

```In article <8amb67\$otd\$1@peabody.colorado.edu>,
> Vmax - 5*log(v) = a[m15-1.1] + b[m15-1.1]^2 + c
>
Orear (1982, Am.J. Phys, 50, 912) give the following solution for
fitting a polynomial with errors in both X. and Y. One uses standard
fitting techniques (e.g. POLYFITW or Craig Markwardt's MPFIT) with the
error only in the Y coordinate, but with the Y error replaced by an
effective variance.
err^2 = erry^2 + ((dy/dx)*errx)^2
In the case of a quadratic y = a*x^2 + b*x +c you would have
err^2 = erry^2 + ((2*x*a +b)*errx)^2
Now the coefficients a and b what you are trying to find, so that one
has to iterate. Start by fitting with only the Y errors, solve for a
and b, then compute the effective variance and redo the fit. Continue
as necessary.
Now before any statisticians lurking in the group start gagging, I
should say that the above algorithm is *not* correct. I believe that
the Orear paper was criticized for its use of a Taylor approximation in
deriving the accuracy of the effective variance method. But the correct
method of dealing with errors in both coordinates is a real bear even in
the linear case (e.g.
http://idlastro.gsfc.nasa.gov/ftp/pro/math/fitexy.pro) and I suspect
that dealing with a quadratic would be much more complicated. And the
effective variance method is certainly better than simply ignoring the X
errors, and provides an intuitive way of giving low weights to data
points if either X error or the Y errors are large.
Its been a while since I looked at this problem, so others may have more
current information.
-Wayne Landsman landsman@mpb.gsfc.nasa.gov

Sent via Deja.com http://www.deja.com/