Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.graphics.apps.gnuplot > #270

Re: Fitting: How does gnuplot calculate the covariance matrix?

From Ingo Thies <ingo.thies@gmx.de>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Fitting: How does gnuplot calculate the covariance matrix?
Date 2011-04-16 18:06 +0200
Message-ID <90tt4sFj9bU1@mid.individual.net> (permalink)
References (2 earlier) <90e7s7F9faU1@mid.dfncis.de> <90h3ttF39uU1@mid.individual.net> <4DA3725D.3040306@t-online.de> <90ik9hF7p0U1@mid.individual.net> <90rtluF8muU1@mid.dfncis.de>

Show all headers | View raw


Am 2011-04-16 00:03, schrieb Hans-Bernhard Bröker:

> Where do you think I did anything arbitrary?

The assumption that the largest a (i.e. a+a_err) corresponds to the 
largest b (b+b_err) is arbitrary and actually wrong if the a,b are 
anticorrelated. Rather, if b_max=b+b_err is given, the corresponding a' 
is minimizing chi^2 for this condition (see Numerical Recipes in 
C/Fortran, Chapter 15.6). This can be done by following the 
68.3%-probability ("1 sigma") contour until b becomes maximal. If 
anticorrelated, a' will be closer to a-a_err rather than a or even a+a_err.

My own fault just was to pick the wrong degree of freedom (dfree). While 
the goodness-of-fit estimation requires dfree=ndata-npar (=21-2=19 in 
our example), the confidence ellipse for combined (a,b) needs 
dfree=npar=2, and for separate a and b errors, dfree=1. Then the 
ellipses (or, more generally, contours, since they are not necessarily 
perfect ellipses) are smaller than the (a,b) confidence levels, but give 
you the position of an extreme parameter and its corresponding 
counterpart geometrically. If you have a copy of the Numerical Recipes 
in your library, Figure 15.6.4. gives a good illustration for what's 
going on.

After correcting the degrees of freedom and redoing the fit for 
chi^2=ndata-npar, the errors are now nearly identical to those of 
gnuplot, at least, if the error contours are near-elliptical. If they're 
not (i.e. errors are not Gaussian), the errors are larger, but probably 
less meaningful.

> Yes, that's what this particular model function does. That was your
> choice, not mine. A different model, e.g. a*(x-x0), might yield a
> different behaviour.

If the error corridors are calculated by following the confidence 
ellipses, they are indeed independent from the choide of x0, although 
the best-fit a and its errors change.

>> All (a,b) at small steps around the ellipse.
>
> A misunderstanding. I was asking: where in that ellipse did those
> numbers your quote as errors of a and b come from?

The extremal a-values minus a_bestfit are taken as a-errors, and the 
same with b.

-- 
Gruß,
       Ingo

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-08 13:05 +0200
  Re: Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-08 17:18 +0200
    Re: Fitting: How does gnuplot calculate the covariance matrix? Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2011-04-10 19:31 +0200
      Re: Fitting: How does gnuplot calculate the covariance matrix? Charles Allen <ca137tmp@earthlink.net> - 2011-04-10 20:14 -0500
        Re: Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-14 15:41 +0200
      Re: Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-11 21:42 +0200
        Re: Fitting: How does gnuplot calculate the covariance matrix? Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2011-04-11 23:27 +0200
          Re: Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-12 11:28 +0200
            Re: Fitting: How does gnuplot calculate the covariance matrix? Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2011-04-16 00:03 +0200
              Re: Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-16 18:06 +0200
      Re: Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-14 15:07 +0200
      Re: Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-15 13:47 +0200
  Re: Fitting: How does gnuplot calculate the covariance matrix? Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2011-04-10 19:04 +0200
    Re: Fitting: How does gnuplot calculate the covariance matrix? Ingo Thies <ingo.thies@gmx.de> - 2011-04-11 22:13 +0200

csiph-web