Get correct fit parameter errors

I am trying to fit some points using the function “pol1”. In the fitting, in order to get better error estimate, I used “E”. After fitting, I try to get fitting parameters and their errors. The errors gotten by, for example, fun->GetParError(0), are the one without using the option “E”. My question is: how to get correct errors and parameters with “E”? My 2nd question: I also try to plot confidence intervals, the errors are likewise the ones without “E”, how to plot correct confidence intervals of fitting with “E”?

I attached an example code and input ROOT file to run the code.

Thank you,
test_fit.C (637 Bytes)
test_fit.root (26.7 KB)

I find the solution for my 1st question:

  double eplus, eminus, eparab, gcc;
  gMinuit->mnerrs(0, eplus, eminus, eparab, gcc); //get par0's errors
  gMinuit->mnerrs(1, eplus, eminus, eparab, gcc); //get par1's errors

Still looking for the solution of my 2nd question.


A better way for getting the asymmetric error is to use the TFitResult class.
In your code do:

 TFitResultPtr r = graph->Fit("pol1", "ES", "", 0.00001, 0.2);
  double p0err_low = r->LowerError(0); 
  double p0err_up = r->UpperError(0); 

The confidence intervals of the fitted functions are calculated using error propagation. This is fully correct only in the linear approximation (i.e. for linear fits). Asymmetric errors are also not taken into accounts.
You should then use a MC method or a Bayesian calculation.

Best Regards


Actually, I do not really care about asymmetry of errors. I just care about the confidence band correctly reflects errors. I read all code related with calculation of a confidence band, it seems to me that covariance matrix is crucial:

Double_t* fVhmat [fMaxpar5] (Internal) error matrix stored as Half MATrix, since it is symmetric
in TMinuit. If fVhmat stores correct error matrix by minos, then I believe the returned confidence band is correct.

My example above is linear fitting. However, error returned by default fitting algo does not make sense. Hence its confident band is very narrow, which does not make sense either.