Behavor of Chisq2 fit with limited range

I’ve been seeing some things I don’t understand when using the chi2FitTo() method [the histogram I want to fit has uncertainties that do not follow a Poisson distribution, so a likelihood fit isn’t appropriate). I decided to go back to the Root Roofit tutorials. I modified rf602_chi2fit to do several fits (using the data generation and model from the original example). The chisq and likelihood fit over the full range of the histogram look reasonable, but when I limit the range of the fit, the chisq fit behaves poorly (even though Minuit reports that it has converged). I’ve attached my modified code and a display of the fit results. Please note that the reported chisq values on the plot are just taken from frame->chiSquare() and is not corrected to the true number of degrees of freedom. I must be making a very basic mistake in how I am implementing the fit, but I don’t see what I am doing wrong.rf602_chi2fit-Modified.C (4.2 KB) chisqFitTest.pdf (60.5 KB)

Hi Marjorie,

I modified your script - for some reason you subtracted the new fit results from the previous ones. That cannot work, since these are pointers to fit results. Admittedly, you didn’t use the results, so no harm done.
Then, I used the fit results to extract the number of fit parameters. That can be used to correct the chi2/ndf, so here’s the result:

The odd thing you see for the normalisation in the bottom right panel is a bug in RooFit, which cannot figure out to which range the function should be normalised to. (RooFit just guesses that you want it to be normalised to the fit the was run last, but for some reason that is “fit_chi2_model_modelData_binned,fit_nll_model_modelData_binned”, so it thinks it has to normalise to the range from the chi2 fit + the range from the nll fit, which are probably the same. Normalisation therefore wrong by a factor two.)
This can easily be fixed by explicitly choosing the plotting and normalisation range (I did that in the attached version of your script).

I will search and fix the bug that leads to the weird double range, but in the mean time, please try my macro. We might be using different root versions, so let’s first see if the changes in the macro get rid of your problem.
rf602_chi2fit_modified.C (4.5 KB)

Ok, the problem is found. The NormRange will be unnecessary in root 6.22.

Thanks for the quick reply. I confirm that the updated macro fixes the problem. It’s also fantastic that the bug you identified is fixed in the repository.

Cheers
Marjorie

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.