# Error on parameters when fitting

Hello,
I’m making a simple linear fit on some data. The problem I have is that the error the fit procedure gives me on the parameters p0 and p1 are huge… (p0+p1*x)

I use gnuplot to fit the exact same data and it gives me errors on p0 and p1 that are 10 times smaller…

Is there a way to get a better fit ?

To fit my data, I use :
h->Fit(“pol1”);
TF1 * f = h->GetFunction();
double p0 = f->GetParameter(0);
doubpe ep0 = f->GetParError(0);
double p1 = f->GetParameter(1);
double ep1 = f->GetParError(1);

I also tried to call Fit(“pol1”) twice, to try to get a better fit, but it gives me the exact same answer.

Thank you

Hi,

Could you provide a running example, so that we can help you mre specifically?

Thanks,
Philippe.

hmm, that sounds a bit scary : you have to read a bit more about parameter fitting .

It is a fit linear in the parameters, so no iterations and the answer
is obtained with one matrix inversion . Have a look at the tutorial solveLinear.C to see what is involved in a linear fit .

Concerning your parameter errors, Philippe is of course right about a running example but I bet that the the following is going on:

You have supplied data points x,y and NO error ey . The chisquare is now calculated using ey = 1 . One expects the chisquare to be equal to the degrees of freedom in the fit : #data points - #fitted parameters .
So one could also say that in order to give the reduced chisquare the desired value , one could multiply all data point errors by
1/sqrt(chi^2) . As a consequence the fitted parameter errors should then
also be multipled by this number .

It seems that GNUplot does this procedure while ROOT does not .

Eddy

Hello,

[quote]You have supplied data points x,y and NO error ey . The chisquare is now calculated using ey = 1 . One expects the chisquare to be equal to the degrees of freedom in the fit : #data points - #fitted parameters .
So one could also say that in order to give the reduced chisquare the desired value , one could multiply all data point errors by
1/sqrt(chi^2) . As a consequence the fitted parameter errors should then
also be multipled by this number .

It seems that GNUplot does this procedure while ROOT does not . [/quote]

Ok, you are right about this, I supplied no error ey.I am not very familliar with the chisquare and what is the impact of ey. What should be put in ey ? I don’t know a good estimate of the error on each of my data. However, I can say that some of them should be given a lower weight in the fitting procedure, and I know what weight to give them.

A running example would be very helpful…
What are you fitting, a TGraph? A TGraphErrors?
To exclude the possibility of it being a bug in the linear fitter, try fitting it with Minuit (option “F”) and look if the errors are still that big. If they are, look at the solveLinear.C tutorial, the case of linear fitting with weights is illustrated in there.