I find the same values wether I get R-squared from the fit function in Matlab or I calculate it 'by hand'.
% mean of the yobs, total sum of squares, and residual sum of squares %% here I calculate 'by hand' the R-squared, from the general definition (wikipedia!) % use the fit function in Matlab, yobs being the data Here is the Matlab code I use: %% R-squared with the fit function Why Excel and Matlab don't end up with the same fitting parameters? How does Excel computes the R 2 in the 'add trendline' function, as it is obviously not the one from the definition (wikipedia)? In Matlab, using the 'fit' function, the parameters for the fitting function (and then of course the R 2) are not the ones that EXCEL has found.
If I calculate it in excel using 'RSQ()' function (taking the values of the parameters Excel has found for the fitting function), or by hand using the definition (wikipedia). I plot the data, fit a power law function ('add trendline') and use the 'add trendline > options > Display R-squared value on chart' In short, I can't find the equations Excel uses for R 2.