Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


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

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-11 21:42 +0200
Message-ID <90h3ttF39uU1@mid.individual.net> (permalink)
References <9088euFi3iU1@mid.individual.net> <908n9pF2jaU1@mid.individual.net> <90e7s7F9faU1@mid.dfncis.de>

Show all headers | View raw


Am 2011-04-10 19:31, schrieb Hans-Bernhard Bröker:

>> a = 9.482095E-01 -/+-1.947044E-01, 1.947043E-01
>> b = 4.270960E-01 -/+-8.327496E-02, 8.327495E-02
>
> Those errors are _way_ too big. Do yourself a favour and plot your data
> along with the model, using parameters modified by those errors:

Well, I plotted the enveloping contours for all (a,b) sets on the 
1-sigma contour, and found that the resulting two curves nicely embrace 
the majority of data points, and the "error pipe" is about the same size 
as the errorbars. And along this 1-sigma contour a and b walk through 
the error intervals above.

In particular, the upper right figure in this poster has been created 
this way:

<http://www.iac.es/congreso/constellation10/media/posters/Thies_poster.pdf>

Please note that the error pipe is based on the 1 and 2 sigma level 
corresponding to chi^2-chi_min^2 rather than chi^2 itself.

>
> [assuming 'set fit errorvar' active, and fit done:]
>
> gnuplot> p 'fit.dat' u 1:2:3 w err, a*x+b w l

You mixed up a and b here; it is actually f(x)=a+b*x

> gnuplot> rep (a+a_err)*x+b+b_err, (a-a_err)*x+b-b_err
> gnuplot> a_thies=0.195
> gnuplot> b_thies=.083
> gnuplot> rep (a+a_thies)*x+b+b_thies, (a-a_thies)*x+b-b_thies
>
> You'll see that gnuplot's a_err and b_err yield a corridor somewhat
> tightly containing almost all data points and their errors, just like it
> should be.

The problem hier is that a and b are anti-correlated (the correlation 
coefficient in the lower-left of the matrix is negative), i.e. the 
larges b corresponds to the smallest a and vice-versa. The only viable 
way to plot the error pipe (or corridor) is to use the actual (a,b) 
tuples from the 1 (or 2, 3 etc.) sigma contour. Or, at least, combine 
the largest a with the smallest b:

[...]
gnuplot> rep a+a_thies+(b-b_thies)*x, a-a_thies+(b+b_thies)*x

-- 
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