Coefficient of determination in ROOT

Dear ROOTers:
Is there a way to get the coefficient of determination (usual known as r-square) of a fit in ROOT?


We don’t have a function in ROOT for getting R-square directly. However, should be quite easy to compute it from the chi2 (the sum of the residual square) that you get after the fit and from the sample variance of the observations, that you can compute using for example TMath::RMS

If you need a code example, please send me you fitting code and I could provide you the code to compute it

Best Regards


Dear Lorenzo.
Sorry for the delay.
I have been working on other application and just got back again to this problem.
I think that i have managed to calcullate the R-square.
I am sending in attachment a “slice” of my code.
Was the same that you have in mind?
Please feel free to comment

FitTESTE.C (3.53 KB)
histogramTESTE.root (14.3 KB)

Sorry to jump in on such an old post, but isn’t the R^2 just the square of GetCorrelationFactor() for 2d histograms or graphs? Also, I would like to advocate to remove the “chi-square” from the default TPaveStats for TGraph fits since it is not statistically meaningful. In these cases, I think the R^2 should be displayed instead.