Home | News | Documentation | Download

Nll value (goodness-of-fit) with SumW2Error()

Dear experts,

I am using RooFit to make a weighted binned likelihood fitter with Extended() and SumW2Error() options. According to the manual, minNll() is not usable while SumW2Error() is enabled.
I also tried to do a likelihood scan on one of the fit variables, and it turned out the likelihood distribution didn’t make sense as well.

Therefore, I am wondering if there any other alternative way to represent the goodness of a fit for this case? Calculating chi^2 manually by using the fit result is one way, but if RooFit provides other number instead of nll for this case, such that we can calculate significance level or upper limit for a specific PDF?
Thank you in advance.

For computing goodness of fit in this case you need to compute the chi^2. There is a function in RooPlot for doing this, see ROOT: RooPlot Class Reference.
Note you cannot use the likelihood ratio to compute in this case confidence intervals (e.g. Minos errors) or significances.

Best regards


Thank you very much. I tried that chi2Square is working in 1D case by using RooPlot and the corresponding data and PDF.
I am wondering if it can work for a 2D fit case (2D histogram and 2D PDF)?
Looks like RooPlot doesn’t support to plot a 2D object on a 2D frame:

RooPlot *rplot = new RooPlot(x,y);
float chi2 = rplot->chiSquare(“pdf”,“data”,N);

The error message is:
[#0] ERROR:InputArguments – RooDataHist::data:plotOn: frame does not specify a plot variable
[#0] ERROR:Plotting – RooAddPdf::pdf:plotOn: frame does not specify a plot variable

For plotting a 2d dataset in a RooPlot you should use RooDataSet::plotOnXY as in this tutorial:



Thank you. But if I use plotOnXY for the data set and PDF, there will be error message:
RooPlot *rplot = new RooPlot(x,y);

error: ‘class RooDataHist’ has no member named ‘plotOnXY’
error: 'class RooAddPdf’ has no member named ‘plotOnXY’
Even if I use the latest version (6.24), the error is still there?
If there anything wrong in my utilization?

This is not correct. You should look at the tutorial, and do:

RooPlot * rplot = x.frame(); 
data.plotOnXY(rplot, YVar(y));

If you create a RooPlot directly will not be linked to the data.
However I see that you are using a RooDataHist, and RooDataHIst has not a dataXY function. This is only for RooDataSet, for plotting (X,Y) points. If you have instead a 2D histogram, i.e. (x,y) values + weight , these are 3d data and cannot be used for a RooPlot.
In this case you should plot the 2D data histogram with the pdf, you need to plot directly the ROOT histogram, without using RooPlot, and the pdf as a TF2 or as a TH2 by using crceateHIstogram.
An example of a multi-dim model is


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