covQual with SumW2Error

Hi all,

I am trying to do a fit to a weighted dataset where I use the line:

When I use the flag kTRUE for SumW2Error, the RooFitResult always returns -1 when calling covQual(). Is there a way to use this option and still be able to see the quality code of the covariance matrix?

Thanks,
Espen

Hello Espen,

I do nto have a reply, but I would be interested to know this myself very much ! Especially since when I observe the output of RooFit I see my fit converged OK and HESSE returned fully accurate error matrix

[…]
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=-1.25848e+06 FROM HESSE STATUS=OK 1131 CALLS 8352 TOTAL
EDM=0.0099749 STRATEGY= 1 ERROR MATRIX ACCURATE
[…]

Just after the SumW2Error correction procedure is called :

[#1] INFO:Fitting – RooAbsPdf::fitTo(simPdf) Calculating sum-of-weights-squared correction matrix for covariance matrix
[…]
EIGENVALUES OF SECOND-DERIVATIVE MATRIX:
-4.0591e-01 -5.2892e-02 - […]
MINUIT WARNING IN HESSE
============== MATRIX FORCED POS-DEF BY ADDING 0.409321 TO DIAGONAL.
FCN=-4.38621e+06 FROM HESSE STATUS=NOT POSDEF 1179 CALLS 9531 TOTAL
EDM=3965.75 STRATEGY= 1 ERR MATRIX NOT POS-DEF
[…]

After which the resulting error matrix seems to be not positively definite anymore ?!
The final result looks quite OK , still this is not very reassuring . I found that there are cases when the corrected (SumW2Error) error matrix reports status OK as well, does it mean that unless both are OK, one should rather attempt some fit reparametrization to avoid correlation ? How reliable are the errors if before recalculation the error matrix is accurate and pos def, but after the correction it is not anymore ?

RooFitResult: minimized FCN value: -4.38621e+06, estimated distance to minimum: 3965.75
covariance matrix quality: Unknown, matrix was externally provided
Status : MIGRAD=4 HESSE=0 HESSE=0

Thank you for any ideas/help in understanding this,
Cheers,
Jaroslav

Yes the problem is due in computing the covariance matrix for the likelihood weighted by the square of the weights. In principle it should work fine if you have found a good minimum with the normal weighted likelihood, but errors in the derivative computation can cause this.
Re-parametrizing the problem, for example re-scaling the parameters to values around one, could help reducing the numerical errors. You could also try to use “Minuit2” for minimizing the likelihood and computing the covariance matrix.

Best Regards

Lorenzo

Dear all,
I have a problem similar to the one discussed in this thread. I have a pdf depending on 2 almost uncorrelated parameters (correlation 0.034).
If I fit the weighted data with:
pdf.fitTo(*Weighted_data, SumW2Error(kTRUE)…);

I see the following text in the log:
[#1] INFO:Fitting – RooAbsPdf::fitTo(pdf_sig_t_Bs_fit) Calculating sum-of-weights-squared correction matrix for covariance matrix

prevFCN = 577753.942 COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=577495 FROM HESSE STATUS=OK 10 CALLS 33 TOTAL
EDM=63.959 STRATEGY= 0 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 p0 4.22039e-01 1.49407e-03 5.07209e-02 -1.56561e-01
2 p1 1.01374e+00 1.96107e-02 4.04825e-01 -1.08038e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 36 NPAR= 2 ERR DEF=0.5
2.232e-06 1.532e-06
1.532e-06 3.847e-04
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.05228 1.000 0.052
2 0.05228 0.052 1.000
setting parameter 0 error to 0.001826
setting parameter 1 error to 0.02326
[#1] INFO:Minization – RooMinuit::optimizeConst: deactivating const optimization

RooFitResult: minimized FCN value: 5.775e+05, estimated distance to minimum: 63.96
covariance matrix quality: Unknown, matrix was externally provided
Status : MIGRAD=0 HESSE=0 HESSE=0

(Note, the fit with the option SumW2Error(kFALSE) nicely converges)

I tried a different approach to fit, by using RooNLLVar:
RooNLLVar *nll_nof = new RooNLLVar(“nll_nof”,"-log(L)",
pdf_sig_t_Bs_fit,*Weighted_data,SumW2Error(true));
RooMinuit m1(*nll_nof);
m1.migrad(); m1.hesse(); m1.save();

and the log looks as if the convergence is nice, however I get exactly the same output commenting
the command SumW2Error(true), so I fear that Minuit is not accounting for the sum-of-weights-squared correction matrix, so the errors are not correct.

Could you tell me which is a proper way of configuring the fit that accounts for sWeights with RooMinuit?
How can I solve the problem of convergence with fitTo (here it doesn’t seem the problem is related to the correlation between parameters)

I tested both root v5.34/07 v5.34/30 and v5.34/32

Thanks
Stefania

Hi

When running the weighted fits, what it is done is a correction to the covariance matrix using the square of the weights in the likelihood. So the minimisation should be the same with or without weights. Since, your output is truncated it is not very clear to me.

In case, I would you suggest to run with Minuit2 ( option RooFit::Minimiser(“Minuit2”) ), which produces a clearer output and with RooFit::PrintLevel(1) or even 2. You can send me the full output if you want me to check if the fit is correct.
You can also see if the minimum likelihood value is the same when doing a weighted fit or not. Only the errors should be different

Best Regards

Lorenzo

Dear Lorenzo,
thanks for your reply. The full output with Minuit and Minuit2 are attached. Indeed the central values don’t change, only the errors.
Also with Minuit2 Hesse seems to be def positive, but then the final coequal is <0

Thanks for any explanation
Cheers,
Stefania
output_Minuit.txt (9 KB)
output_Minuit2.txt (6.85 KB)