Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: peterchun <peter.chun@ma...>  20081029 00:11:48

Hi, I am having some problems with the fit of a straight line. I want to get a line of best fit for the 3rd column. It really should give for f(x)=m*x+c m=0 c=293255 but I get m=close to 0 c=1 I do not understand how I get a line of best fit that does not fit What am I doing wrong? Thanks Peter data: 26/08/08 293449 293255 10/09/08 296787 293255 12/09/08 296787 293255 15/09/08 296787 293255 17/09/08 296787 293255 18/09/08 296787 293255 19/09/08 296787 293255 20/09/08 296787 293255 21/09/08 296787 293255 22/09/08 296787 293255 23/09/08 296787 293255 24/09/08 296787 293255 25/09/08 296787 293255 26/09/08 296787 293255 27/09/08 296787 293255 28/09/08 296787 293255 29/09/08 296787 293255 30/09/08 296787 293255 01/10/08 296787 293255 02/10/08 296787 293255 03/10/08 296787 293255 04/10/08 296787 293255 05/10/08 296787 293255 06/10/08 296787 293255 07/10/08 296787 293255 08/10/08 296787 293255 09/10/08 296787 293255 10/10/08 296787 293255 11/10/08 296787 293255 12/10/08 296787 293255 13/10/08 296787 293255 14/10/08 296787 293255 15/10/08 296787 293255 16/10/08 296787 293255 17/10/08 296787 293255 18/10/08 296787 293255 19/10/08 296787 293255 20/10/08 296787 293255 21/10/08 296787 293255 22/10/08 296787 293255 23/10/08 296787 293255 24/10/08 296787 293255 25/10/08 296787 293255 26/10/08 296787 293255 27/10/08 296787 293255 28/10/08 296787 293255 29/10/08 296787 293255 gnuplot commands: dataset="data" set xdata time set timefmt "%d/%m/%y" set style data boxes set style fill solid 1 noborder set xrange [ "29/07/08":"29/01/09" ] set title "data" set xlabel "date" set ylabel "whatever" set grid f(x)=m*x + c fit [ "29/09/08":"28/10/08" ] f(x) dataset using 1:3 via m,c plot dataset using 1:2 title "line1", dataset using 1:3 title "line2" , f(x) title "Trendline" lw 3  View this message in context: http://www.nabble.com/fitfunctionweirdnesstp20218720p20218720.html Sent from the Gnuplot  User mailing list archive at Nabble.com. 
From: HansBernhard Bröker <HBBroeker@t...>  20081029 11:55:55

peterchun wrote: > Hi, > I am having some problems with the fit of a straight line. > > I want to get a line of best fit for the 3rd column. > It really should give > for > f(x)=m*x+c > m=0 > c=293255 Sorry, but for technical reasons 'fit' fails at finding zeroes as target parameters. The problem is with the way we compute derivatives WRT parameters. Moreover, even if that did work, it also doesn't work well to have fit parameters with wildly different orders of magnitude. Zero is infinitely different from all other numbers in that respect... :( So you'll have to shift the m parameter away from zero. Something like: f(x) = (m2e5)*x + c 
From: Thomas Sefzick <t.sefzick@fz...>  20081029 11:55:56

a) you are using 'set xdata time'. so the origin of the coordinate system is ("01/01/2000" , 0). that means that the point where 'c' is calculated (point of origin) is far off the point where your data are: appr. +2.8e+8 seconds. this can not work. for the function f(x)=m*(x2.8e+08) + c the fit behaves a little bit better when setting 'c' to a value near enough to 293255. but in the end it will terminate with the message Singular matrix in Invert_RtR maybe it's because the fit is working at the limit of computational accuracy? i'm not sure about that... b) for data distributed on a horizontal line you should use an appropriate function, e.g. f(x)=a and the fit will converge after 4 steps. > Hi, > I am having some problems with the fit of a straight line. > > I want to get a line of best fit for the 3rd column. > It really should give > for > f(x)=m*x+c > m=0 > c=293255 > > but I get > m=close to 0 > c=1 > > I do not understand how I get a line of best fit that does not fit > What am I doing wrong? > > Thanks > Peter > > data: > 26/08/08 293449 293255 > ... > 29/10/08 296787 293255 > > gnuplot commands: > dataset="data" > set xdata time > set timefmt "%d/%m/%y" > set style data boxes > set style fill solid 1 noborder > set xrange [ "29/07/08":"29/01/09" ] > set title "data" > set xlabel "date" > set ylabel "whatever" > set grid > f(x)=m*x + c > fit [ "29/09/08":"28/10/08" ] f(x) dataset using 1:3 via m,c > plot dataset using 1:2 title "line1", dataset using 1:3 title "line2" , > f(x) title "Trendline" lw 3  View this message in context: http://www.nabble.com/fitfunctionweirdnesstp20218720p20225280.html Sent from the Gnuplot  User mailing list archive at Nabble.com. 
Sign up for the SourceForge newsletter:
No, thanks