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


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

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-14 15:07 +0200
Message-ID <90o9s9F5aiU1@mid.individual.net> (permalink)
References <9088euFi3iU1@mid.individual.net> <908n9pF2jaU1@mid.individual.net> <90e7s7F9faU1@mid.dfncis.de>

Show all headers | View raw


On 10.04.2011 19:31, Hans-Bernhard Bröker wrote:

> gnuplot> p 'fit.dat' u 1:2:3 w err, a*x+b w l
> 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

I have modified the model function to minimize the correlation of a and
b. This has been done by substituting x by x-x0, where x0 is the mean of
all x (2 in this case). Here is the full script, to be applied to the
same data table ('fit.tab'). To enhance visibility, I have given
different colors for the different error types (blue for gnuplot's, red
for mine). Please look again at the errors. Are they still _way_ too
large? Or aren't gnuplot's errors now _way_ too small?

set fit errorvar
#x0=0.; a_thies=0.195; b_thies=0.083 # old fit
x0=2.; a_thies=0.101; b_thies=0.083 # new fit
f(x)=a+b*(x-x0)
set xrange [0:4]
set yrange [0.5:3]
fit [0:4] f(x) xfile u 1:2:3 via a,b
set key left
p a+b*(x-x0) w l lc rgb '#0000ff',\
  a-a_err+(b-b_err)*(x-x0) lc rgb '#007fff',\
  a+a_err+(b+b_err)*(x-x0) lc rgb '#007fff',\
  a-a_thies+(b-b_thies)*(x-x0) lc rgb '#ff0000',\
  a+a_thies+(b+b_thies)*(x-x0) lc rgb '#ff0000',\
  'fit.dat' u 1:2:3 w err lc rgb '#000000'

I would find it highly confusing if the error corridors depend on a
simple substitution. If one plotts the a,b error contours, and uses them
for the error estimate (i.e. walks around the 1-sigma contour in the a-b
space and creates the enveloping curve for all possible resulting
functions), then the "way-too-large" error for the slope b remains
constant. Only the error for the offset a changes, as expected.

-- 
Gruß,
      Ingo

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


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