Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problems with fit on time data

368 views
Skip to first unread message

jean cool

unread,
Dec 19, 2009, 6:49:48 PM12/19/09
to
Hi,

I have got some time data I'm using fit command on. The data is a
decaying exponential levelling off aroud 0.75 and with a time constant
of about 30 days.

I have managed to get around the usual problems by scaling x and fit
returns values close to what I expected but not correct. My problem is
in plotting the resulting function.

The first worry is that I had to frig the x offset by checking a
cursor value. The epoch in seconds that I expected to be the plotted x
data did not work (see commented out value from linux data command). I
don't understand why the output of date does not correspond to the x
cursor coordinates.

Second problem is in plotting the fitted function. It looks like a
climatologist's hockeystick in reverse. It starts from the first data
point and drops steeply to its final value and then goes straight
across. It seems like a scaling problem but attempts to scale it
differently don't get it better.

Can anyone see where I am going wrong?

TIA.


set timefmt "%d.%m"
set xdata time

a=0.9;b=3;
c=-30
# date --date="2009-09-18 " +%s
k=1253224800
k=2.255e+07/86400


f(x)=a+b*exp(c*(x-k))
fit f(x/86400) datafile using 1:2 via a,b,c

plot s=0\
, datafile using 1:($2) t "euremie" w l\
, f(x/86400)


console output from fit :

Final set of parameters Asymptotic Standard Error
======================= ==========================

a = 1.37 +/- 0.5948 (43.42%)
b = 1.56276 +/- 1.803e+16 (1.154e+18%)
c = -30.0176 +/- 2.492e+18 (8.302e+18%)

Hans-Bernhard Bröker

unread,
Dec 20, 2009, 12:06:10 PM12/20/09
to jean cool
jean cool wrote:

> The first worry is that I had to frig the x offset by checking a
> cursor value.

That's because this

> # date --date="2009-09-18 " +%s
> k=1253224800

is wrong. gnuplot's epoch is not that of the Unix 'date' command, so
referring to 'date' is not terribly helpful. You're about 30 years'
worth of seconds off, because gnuplot's epoch is 2000-01-01, not 1970-01-01.

> k=2.255e+07/86400

> Second problem is in plotting the fitted function.

Not really. Your second problem is that the fit itself is bollocks, as
clearly visible if you look at the fit parameter errors:

> Final set of parameters Asymptotic Standard Error
> ======================= ==========================
>
> a = 1.37 +/- 0.5948 (43.42%)
> b = 1.56276 +/- 1.803e+16 (1.154e+18%)
> c = -30.0176 +/- 2.492e+18 (8.302e+18%)

8e18 percent indicates beyond any reasonable doubt that this fit didn't
work. It means fit couldn't get your chisquare to depend on those input
parameters at all. A serious part of the blame for that failure goes to
how you set up parameter 'c':

> c=-30
> f(x)=a+b*exp(c*(x-k))

These two don't match your text description about a time constant of
about 30 days. For that, you would need

c = -30 ; f(x) = a + b*exp((x-k)/c)
or c = -0.03 ; f(x) = a + b * exp(c * (x-k))

By your construction, you're about 3 orders of magnitude away from your
stated goal --- no wonder the fit didn't find a solution. A plot of
function and model before the fit command would have shown that.

0 new messages