Bug with GetParError?

Hi all!

I’m using ROOT v5.14.00.
I send you here a small macro to test GetParError function after a fit.
It seems that it doesn’t give the same error than sqrt(fitter->GetCovarianceMatrixElement(0,0))…
For me, running my macro gives:

compare 0.0941582 et 0.978065
compare 0.0886698 et 0.921054

Have you got an idea what is wrong here ??

Thank you!
test2.C (1.26 KB)

In your example you are creating a TGraphErrors where all errors are 0.
This is of course a bad condition for the fitter that cannot make a good estimate of the errors (simply taking sqrt(covmatrix element).
In this particular case, we recompute the errors on parameters by
multiplying the covmatrix element by sqrt(chisquare/(ndf-1).
This provides a much better estimation for the errors on parameters.

If you set the errors, you will see that the parameter error stored in TF1
and the sqrt(covmatrix) are identical.


Hi !

ok thank you for the quick reply.

But if i replace the line:
TGraphErrors *gr = new TGraphErrors(n, l_TabularX , l_TabularY , l_TabularDeltaX, l_TabularDeltaY);

TGraph *gr = new TGraph(n, l_TabularX , l_TabularY);

I have still the same difference.

Does that mean that anyway i have to prefer the method GetParError to estimate errors ?
Thank you!

By definition the TGraph has no error. So in this case, we automatically apply the optimisation algorithm described above.
Yes, TF1::GetParError always provides a better error estimation.


Ok thank you!
And last question about this subject:

If i’m interested by the covariance, should i multiply
fitter->GetCovarianceMatrixElement(0,1) by Chi2/(NDF-1) for having a better estimation (in the case GetParError(0) gives a different result than
fitter->GetCovarianceMatrixElement(0,0) ) or not ??

Thank you very much!

As I said, the multiplication of the covmatrix element by sqrt(chi2/ndf-1) is automatically applied by TGraph::Fit in case no errors on the fitted points are provided.
If you provide errors on the points, then TF1::GetParError
should be equal to the sqrt of the covmatrix element…


Hi. I have a related problem. I am fitting a simple pol2 function ( [0]*pow(x,2)+[1]*x) to different TgraphErrors with only errors in the y axis.

In some cases (not in all my tgraphserrors), there is a difference between the uncertainties obtained for one of the fit parameters, when I use the method getparerror(0) or (1) and whem I calculate the sqr of the covariance matrix element (0,0) or (1,1). Also the uncertainty in this cases is bigger when I use the getparrerror() method. And the uncertainty is bigger than the parameter value.

When this happened for one parameter, for the other the uncertainties match with both methods and the values are much smaller than the parameter value as it should be for a useful fit.

I want to know which method gives me the correct value for the parameter error in these cases. And I want to know if the covariance matrix element (1,0) is well estimated also when this happens.