I have mis-understanding about the correction of errors when doing fit with weigths, using the option: Sumw2Error.
I posted a macro to make a simple test of this option, to understand it:
I generate 8000 events from gaussian and uniform distribution, and then I fit them with 3 cases:
-all events weighted with the same weight (w=4), but without correction for error
-all events weighted with the same weight (w=4), with correction for error.
So, I expected for my example that the corrected loglikelihood should be corrected by a factor sum w/ sum w^2 = 1/4
So the error on fitted parameters should be corrected by a factor sqrt(4)=2.
And on my example, we can see results on nsig:
-no weights: 3012 +/- 61
-weighted without error correction: 12050 +/- 121
-weighted with error correction: 12050 +/- 33
That means with the error correction Sumw2Error, errors are even more under-estimated. I expected that the corrected error should be sqrt(4)=2 times more than the uncorrected one.
PS: I used root version 5.34/04
Could you help me if I did a mistake in my code, or if I mis-understand the correction process or if it could have a bug with the option Sumw2Error.
Thank you very much,
testfit_weight.C (5.35 KB)
I think there was a problem with the old version. With the latest 5.34 (e.g. 5.34.23), I get the correct error with the Sumw2 correction of 240 (i.e. w * uncorrected_error).
Thank you, I will try with the latest root version.
I have checked, the fix for weighted extended likelihood fit is from ROOT version >= 5.34.19
Thank you Lorenzo for your check.
I ran with success my test macro with root 5.34/23, and I am wondering why for the case with Sumw2Error, the error printed on the table is not the expected one but the corrected error is printed after, as [quote]setting parameter 2 error to 242.26[/quote]…
The error on the table seems to be the error without weight.
This corrected error, is it well calculated using the corrected loglikelihood or is it "simply evaluated by w*uncorrected_error?
You are looking at the intermediate values printed by Minuit. These values refer to one of the two minimisations which are done, one where the likelihood is weighted using w and one where the likelihood is weighted using w^2. The covariance matrix is then corrected using the procedure described in F. James book, “Statistical Methods in Experimental Physics”, par 8.5.2 in particular equation 8.48.
So you should look at the final error, what is given for example by RooFitResult::Print()
Ok I understand better now,