Re: [Veusz-discuss] Bad fit

2014-11-26 Par sujet Fred Labrosse
I now understand, thanks for explaining that.

Fred


On Wednesday 26 November 2014 17:26:11 Jeremy Sanders wrote:
> The issue is that the 5% of the lower value points is less in absolute
> terms than 5% of the higher value points, so the lower y values are
> weighted more in the fit. These are the outliers. It's the relative
> absolute uncertainty of each point which is included in the weighting
> 
> Essentially the minimiser is minimising
> 
> Chi^2 = Sum( ((Data-Model)/(Uncertainty))^2 )
> 
> If Uncertainty is constant, than we try to get the minimum squared
> deviation of the data from the model. If Uncertainty is 5% of Data, then
> the lower Data values are weighted more strongly.
> 
> Cheers
> 
> Jeremy
> 
> On 26/11/14 16:15, Fred Labrosse wrote:
> > I think my point was more that if I specify "y,5" for the y, which is
> > close to 50% of the values, then I get a reasonable result while if
> > the default 5% is used, then I don't.  Or did I miss something?
> > 
> > Cheers,
> > 
> > Fred
> > 
> > On Wednesday 26 November 2014 13:39:16 Jeremy Sanders wrote:
> >> On 26/11/14 13:31, Fred Labrosse wrote:
> >>> Thanks, that did it.  Interestingly enough, the console said
> >>> "Warning:
> >>> No errors on y values. Assuming 5% errors", which I thought was
> >>> appropriate. Clearly not.
> >>> 
> >>> However, it seems that whatever value I specify as an error makes it
> >>> work. y,5 gives more or less the same as y,0.1...
> >> 
> >> Yes, it's 5% not 10%. The reason it fails with fractional errors is
> >> that
> >> the lower the y value the lower the uncertainty. Your outliers have
> >> low
> >> y values and so they get extra weight because they have lower
> >> uncertainties. Any sensible constant y uncertainty value should work
> >> for
> >> your data.
> >> 
> >> A default constant error would have been better. Most of my data is
> >> fitting powerlaws, where the uncertainties are typically fractional,
> >> so
> >> that's probably why I chose that default.
> >> 
> >> Cheers
> >> 
> >> Jeremy
> > 
> > ___
> > Veusz-discuss mailing list
> > Veusz-discuss@gna.org
> > https://mail.gna.org/listinfo/veusz-discuss
> 
> ___
> Veusz-discuss mailing list
> Veusz-discuss@gna.org
> https://mail.gna.org/listinfo/veusz-discuss

___
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss


Re: [Veusz-discuss] Bad fit

2014-11-26 Par sujet Jeremy Sanders
The issue is that the 5% of the lower value points is less in absolute 
terms than 5% of the higher value points, so the lower y values are 
weighted more in the fit. These are the outliers. It's the relative 
absolute uncertainty of each point which is included in the weighting


Essentially the minimiser is minimising

Chi^2 = Sum( ((Data-Model)/(Uncertainty))^2 )

If Uncertainty is constant, than we try to get the minimum squared 
deviation of the data from the model. If Uncertainty is 5% of Data, then 
the lower Data values are weighted more strongly.


Cheers

Jeremy

On 26/11/14 16:15, Fred Labrosse wrote:

I think my point was more that if I specify "y,5" for the y, which is close
to 50% of the values, then I get a reasonable result while if the default
5% is used, then I don't.  Or did I miss something?

Cheers,

Fred


On Wednesday 26 November 2014 13:39:16 Jeremy Sanders wrote:

On 26/11/14 13:31, Fred Labrosse wrote:

Thanks, that did it.  Interestingly enough, the console said "Warning:
No errors on y values. Assuming 5% errors", which I thought was
appropriate. Clearly not.

However, it seems that whatever value I specify as an error makes it
work. y,5 gives more or less the same as y,0.1...


Yes, it's 5% not 10%. The reason it fails with fractional errors is that
the lower the y value the lower the uncertainty. Your outliers have low
y values and so they get extra weight because they have lower
uncertainties. Any sensible constant y uncertainty value should work for
your data.

A default constant error would have been better. Most of my data is
fitting powerlaws, where the uncertainties are typically fractional, so
that's probably why I chose that default.

Cheers

Jeremy


___
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss




___
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss


Re: [Veusz-discuss] Bad fit

2014-11-26 Par sujet Fred Labrosse
I think my point was more that if I specify "y,5" for the y, which is close 
to 50% of the values, then I get a reasonable result while if the default 
5% is used, then I don't.  Or did I miss something?

Cheers,

Fred


On Wednesday 26 November 2014 13:39:16 Jeremy Sanders wrote:
> On 26/11/14 13:31, Fred Labrosse wrote:
> > Thanks, that did it.  Interestingly enough, the console said "Warning:
> > No errors on y values. Assuming 5% errors", which I thought was
> > appropriate. Clearly not.
> > 
> > However, it seems that whatever value I specify as an error makes it
> > work. y,5 gives more or less the same as y,0.1...
> 
> Yes, it's 5% not 10%. The reason it fails with fractional errors is that
> the lower the y value the lower the uncertainty. Your outliers have low
> y values and so they get extra weight because they have lower
> uncertainties. Any sensible constant y uncertainty value should work for
> your data.
> 
> A default constant error would have been better. Most of my data is
> fitting powerlaws, where the uncertainties are typically fractional, so
> that's probably why I chose that default.
> 
> Cheers
> 
> Jeremy

___
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss


Re: [Veusz-discuss] Bad fit

2014-11-26 Par sujet Jeremy Sanders

On 26/11/14 13:31, Fred Labrosse wrote:

Thanks, that did it.  Interestingly enough, the console said "Warning: No
errors on y values. Assuming 5% errors", which I thought was appropriate.
Clearly not.

However, it seems that whatever value I specify as an error makes it work.
y,5 gives more or less the same as y,0.1...


Yes, it's 5% not 10%. The reason it fails with fractional errors is that 
the lower the y value the lower the uncertainty. Your outliers have low 
y values and so they get extra weight because they have lower 
uncertainties. Any sensible constant y uncertainty value should work for 
your data.


A default constant error would have been better. Most of my data is 
fitting powerlaws, where the uncertainties are typically fractional, so 
that's probably why I chose that default.


Cheers

Jeremy


___
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss


Re: [Veusz-discuss] Bad fit

2014-11-26 Par sujet Fred Labrosse
Thanks, that did it.  Interestingly enough, the console said "Warning: No 
errors on y values. Assuming 5% errors", which I thought was appropriate.  
Clearly not.

However, it seems that whatever value I specify as an error makes it work. 
y,5 gives more or less the same as y,0.1...

Not sure I understand.

Fred


On Wednesday 26 November 2014 13:19:52 Jeremy Sanders wrote:
> Dear Fred
> 
> On 26/11/14 12:15, Fred Labrosse wrote:
> > I'm obviously missing something somewhere.  I'm playing with robust
> > linear fit and experimenting with a number of ways of doing it.  So
> > far I have tried GSL and I get the attached result (each line is a
> > point, giving x, y, ordinary least square fit and a robust fit
> > (bisquare)).  I plotted that in veusz to verify this was making sense,
> > and it does.
> > 
> > Then I tried the fit in veusz, specifically a linear fit (function a +
> > bx). What I get does not make sense (sloping down, going from the
> > first to the last (outlier) points).  I restricted the range to ignore
> > the outliers and the fit is much better but still wrong.
> > 
> > What is going on?  What am I missing?
> 
> Did you provide an error bar or uncertainty on your y data? Veusz does a
> chi-squared minimisation and by default assumes 10% of the data value if
> not given an uncertainty. This probably is not a good choice for
> non-logarithmic data. You could try adding a symmetric error to the data
> value and refitting.
> 
> I just tried using 'y,0.1' as the y Data setting (this adds an error bar
> of 0.1 to your y data set) - this seems to give a fit similar to your
> least square result.
> 
> Best wishes
> 
> jeremy

___
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss


Re: [Veusz-discuss] Bad fit

2014-11-26 Par sujet Jeremy Sanders

Dear Fred

On 26/11/14 12:15, Fred Labrosse wrote:


I'm obviously missing something somewhere.  I'm playing with robust linear
fit and experimenting with a number of ways of doing it.  So far I have
tried GSL and I get the attached result (each line is a point, giving x, y,
ordinary least square fit and a robust fit (bisquare)).  I plotted that in
veusz to verify this was making sense, and it does.

Then I tried the fit in veusz, specifically a linear fit (function a + bx).
What I get does not make sense (sloping down, going from the first to the
last (outlier) points).  I restricted the range to ignore the outliers and
the fit is much better but still wrong.

What is going on?  What am I missing?


Did you provide an error bar or uncertainty on your y data? Veusz does a 
chi-squared minimisation and by default assumes 10% of the data value if 
not given an uncertainty. This probably is not a good choice for 
non-logarithmic data. You could try adding a symmetric error to the data 
value and refitting.


I just tried using 'y,0.1' as the y Data setting (this adds an error bar 
of 0.1 to your y data set) - this seems to give a fit similar to your 
least square result.


Best wishes

jeremy


___
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss