comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Help: Weighted quadratic fitting under IDL?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Help: Weighted quadratic fitting under IDL? [message #19406] Wed, 15 March 2000 00:00
landsman is currently offline  landsman
Messages: 93
Registered: August 1991
Member
In article <8amb67$otd$1@peabody.colorado.edu>,
bgibson@spitzer.colorado.edu (Brad K. Gibson) wrote:
> 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/
Before you buy.
Re: Help: Weighted quadratic fitting under IDL? [message #19408 is a reply to message #19406] Wed, 15 March 2000 00:00 Go to previous message
Mark Fardal is currently offline  Mark Fardal
Messages: 51
Registered: October 1995
Member
bgibson@spitzer.colorado.edu (Brad K. Gibson) writes:

> Anyways ... here it is ... the equation of interest is of the form:
>
> Vmax - 5*log(v) = a[m15-1.1] + b[m15-1.1]^2 + c
>
> I have a data file with Vmax, v, and m15 for a set of objects (about 40 of
> them), with uncertainties on each value.
> Having read those entries in, what I want to do is fit the above
> functional form, deriving a, b, and c, as well as their associated
> uncertainties (i.e. a +/- sig(a), b +/- sig(b), and c+/-sig(c)), and the final
> dispersion (and maybe reduced chi-squared) of the best fit quadratic.
>
> Now .. I can see various routines which get me part-way there, but they either
> only provide a,b, and c without uncertainties, or only provide the
> uncertainties for a linear fit (e.g. fitexy). Basically what I'd like is a
> quadratic version of fitexy (i.e., sigmas on all returned coefficients+
> dispersion of fit+reduced chi-square).


How about POLYFITW, or SVDFIT? They both return errors on the fit
coefficients. So you just fit to the dependent variable
y = (Vmax - 5*log(v) ) +- sqrt(sigma^2(Vmax) + 25*sigma^2(v)/v^2)

Hmm...you have errors on m15 too. Is this your question? It's common
to ignore those in the fit, if it's not obvious they are the dominant
error. Lupton's book section 11.7 discusses the problem for linear
fits.

Mark Fardal
UMass
Re: Help: Weighted quadratic fitting under IDL? [message #19409 is a reply to message #19406] Wed, 15 March 2000 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
There is only one answer: MPFIT

Grab it from http://cow.physics.wisc.edu/~craigm/idl/


Cheers,
Martin


"Brad K. Gibson" wrote:
>
> This may be a highly trivial question, but it's one I'm having problems
> dealing with under IDL. Perhaps I"m simply missing something obvious ..
> regardless, I'd be indebted if someone could help me out. Heck, I'll even
> throw in a nice acknowledgement in my next paper, if someone could point me to
> a simple solution, or provide the requisite few lines of code!
>
> Anyways ... here it is ... the equation of interest is of the form:
>
> Vmax - 5*log(v) = a + b^2 + c
>
> I have a data file with Vmax, v, and m15 for a set of objects (about 40 of
> them), with uncertainties on each value.
> Having read those entries in, what I want to do is fit the above
> functional form, deriving a, b, and c, as well as their associated
> uncertainties (i.e. a +/- sig(a), b +/- sig(b), and c+/-sig(c)), and the final
> dispersion (and maybe reduced chi-squared) of the best fit quadratic.
>
> Now .. I can see various routines which get me part-way there, but they either
> only provide a,b, and c without uncertainties, or only provide the
> uncertainties for a linear fit (e.g. fitexy). Basically what I'd like is a
> quadratic version of fitexy (i.e., sigmas on all returned coefficients+
> dispersion of fit+reduced chi-square).
>
> Obviously there is a nice way to do this without doing Monte Carlo
> simulations, but anyone who could save me a few
> hours of hacking code would become my instant hero(ine). Anyone?
>
> Cheers,
> Brad
>
> --
> Brad K. Gibson INTERNET: bgibson@casa.colorado.edu
> CASA, University of Colorado PHONE: +1-303-492-6058
> Campus Box 389 FAX: +1-303-492-7178
> Boulder, CO, USA 80309-0389 http://casa.colorado.edu/~bgibson/

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Plotting double precision (seg fault)
Next Topic: [Q] XInteranimate

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:07:46 PDT 2025

Total time taken to generate the page: 0.00638 seconds