So I have two root files, one that is the expected that has a TGraph *gex and another that is the data has a TGraphAsymmErrors *gdata. I am now fitting my data to the expected.
I open the root files and call the 2 graphs and much like fithist.C tutorial fit my data to my expected. I fit using Fit(“function”,“erf”); The fit seems great and the parameters make sense too.
But when I get the errors on the fit parameters I’m not sure if I am getting the correct values.I am using function->GetParError(0) etc.
For example par[0] has 0.8001 +/- 0.016 and par[1] has 0.0089 +/- 0.0002
So does this mean I can do a manual calculation of chi squared within two loops around the minimum point and get the same values?
For example if I do
loop through par0{
loop through par1{
calculate chi squred for each point of (par0, par1)
for this use chi += (data-pred)^2/sigma^2
}
}
And now if I plot a 1D histo of par0 at the minimum chisquare value of par1, then I can deduce the 1sigma errors with delta(Chi) = 2.3 since there are 2 parameters, right? But this seems to give me different values atleast for par1.
The values I get by this manual method are as follows:
par[0] has 0.95 (+0.32/- 0.24) and par[1] has 0.0089 (+0.0003/- 0.0004)
So this makes me think I am not getting the correct error values at least, with GetParError(0).
first of all the 1 sigma errors are obtained by projecting the contour of the chi2 function at the value minimum+1 on the parameter axis.
You can see for example the figure 1.1. at page 9 in this document seal.web.cern.ch/seal/documents/ … nerror.pdf
Then, in ROOT, since the points in the TGraph do not have errors, the resulting error from the fit are scaled by a factor sqrt( chi2_minimum / ndf)
where ndf is the number of degree of freedom of t he fit (Number of point - number of parameter). This is not happen in the case of TGraphErrors.
Unfortunatly there is also a bug in the error scaling for the TGraph fitting in root 5.22 (but not 5.20 and earlier version), which is now fixed in the trunk (5.23)
" first of all the 1 sigma errors are obtained by projecting the contour of the chi2 function at the value minimum+1 on the parameter axis."
Hmmm… this is true only when you fit 1 parameter. If you are fitting 2 or more parameters, then you have to use the covariance matrix (or error matrix). See table 31.2 of pdg booklet. Accordingly, if I am fitting 2 parameters, I have to use chimin+2.3. Is this not implemented in root?
"Then, in ROOT, since the points in the TGraph do not have errors"
The prediction is a MC simulation. As such it does not have errors. The simulation essentially acts as a fit function. Does ROOT look for errors in the fit function also? I thought I only needed errors in the data graph, hence the usage of TGraphAsymmErrors for the data.