How to get the covariance quality of a fit when using SumW2Error

Hello,

This question is the same as the one that was asked here but which has never got answered.

I’m doing a fit to weighted data, using SumW2Error(True).

For instance, pdf is my model, which I want to fit to (binned) data. I run:

result = pdf.fitTo(
data,
RooFit.Strategy(2), RooFit.SumW2Error(True),
RooFit.Extended(True)
)

(I’m using ROOT with python but that should not change anything here)

Since I need to run many fits (more than 1000), I would like to be able to access the quality of the covariance matrix through a code rather than reading the outputs printed during the fit.
For instance, the output of the fit might tell me:
Info in negative or zero diagonal element in covariance matrix : i = 5
and the covariance matrix cannot be trusted anymore.

However, since I’m using SumW2Error, the covariance matrix quality is said to be Unknown, matrix was externally provided.
Thus, covQual() in result (the RooFitResult object) always returns -1 instead of 1, 2 or 3.

So, my question is: do you know if it is possible to get the quality of the covariance matrix when using SumW2Error?

Anthony.

PS: my ROOT version: 6.22/06

HI @correian!

I agree, RooFitResult::covQual() should return something meaningful here.

What is the behavior that you would expect? There are two covariance matrices when you do RooFit.SumW2Error(True) one for the fit with the original weights, and one for the fit the squared weights. However, RooFitResult::covQual() only returns one int. We could return the quality of the covariance matrix with the worse quality because that’s what limits the quality of the corrected covariance matrix. Or do you need to access the qualities of the individual covariance matrices?

Hello @jonas ,

If I’ve understood you well, the corrected covariance matrix is computed from two covariance matrices, so there are 3 covariant matrices.

If so, for what I want to do, I think it makes sense to return the quality of the covariance matrix with the worse quality (among the three matrices), to check if the corrected covariance matrix has been computed using legit intermediate matrices and is itself legit.

It’s just a suggestion really, perhaps my reasoning is wrong!

I don’t think I need to access the qualities of the individual covariance matrices.

Anthony.

Right, in the RooAbsPdf::fitTo documentation you can see that the final covariance matrix is V_corr = V C^-1 V, so to me it makes sense to define the quality of V_corr as min(qual(V), qual(C)). I can make that clear in the documentation.

The only alternative I can think of without changing the RooFitResult interface is to come up with more possible values of covQual to encode the quality of both matrices, but I think this is confusing and might interfere with the way people use these quality codes.

If I’d implement this with the minimum quality in ROOT, I guess you would benefit from having this in the upcoming release ROOT 6.24?

Re-hello Jonas, thanks for the answer!

I think your solution is much better than mine! I think it would make sense to use more possible values of covQual since it was always returning -1 with SumW2Error anyway ; but indeed I understand it can be confusing.

That would be great if this was implemented in the upcoming release!

I have implemented a pull request that implements what was discussed in this thread:

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