SOLVED

Same XY scatter but different R square

%3CLINGO-SUB%20id%3D%22lingo-sub-2456776%22%20slang%3D%22en-US%22%3ESame%20XY%20scatter%20but%20different%20R%20square%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2456776%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20set%20of%20X%20and%20Y%2C%20as%20below.%3C%2FP%3E%3CTABLE%20width%3D%22288%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2272%22%3EX%3C%2FTD%3E%3CTD%20width%3D%22216%22%3EY%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E0.05%3C%2FTD%3E%3CTD%3E0.28344174663489400%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E0.5%3C%2FTD%3E%3CTD%3E1.26762275157997000%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E1%3C%2FTD%3E%3CTD%3E3.43248288736777000%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2%3C%2FTD%3E%3CTD%3E9.69228927203065000%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E3.5%3C%2FTD%3E%3CTD%3E19.16153253754330000%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E5%3C%2FTD%3E%3CTD%3E26.01969057665260000%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%3CSPAN%3E%3CBR%20%2F%3EIn%20my%20computer%20trying%20Office%202013%2C%202016%2C%20and%202019%2C%20all%20the%20R%20square%20of%20the%20linear%20trend%20is%200.9886%2C%20while%20in%20my%20friends'%20computers%2C%20it's%200.9945.%20We%20used%20SAS%20and%20SPSS%20to%20calculate%2C%20which%20also%20showed%20R2%3D0.9945.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EWe%20set%20the%20intercept%20%3D%200.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20anything%20wrong%20with%20my%20computer%3F%3C%2FP%3E%3CP%3EHow%20can%20I%20fix%20it%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2456776%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2457226%22%20slang%3D%22en-US%22%3ERe%3A%20Same%20XY%20scatter%20but%20different%20R%20square%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2457226%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1081094%22%20target%3D%22_blank%22%3E%40linnan5945%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20get%200.9945%20in%20Excel%202019%20with%20your%20data.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22S0515.png%22%20style%3D%22width%3A%20479px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F289506iF09B8FEECAF6B851%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22S0515.png%22%20alt%3D%22S0515.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWhat%20do%20you%20see%20if%20you%20open%20the%20attached%20workbook%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2461186%22%20slang%3D%22en-US%22%3ERe%3A%20Same%20XY%20scatter%20but%20different%20R%20square%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2461186%22%20slang%3D%22en-US%22%3EWow%20cool.%3CBR%20%2F%3ESo%20how%20can%20I%20change%20the%20trendline%20to%20use%20LINEST%20result%20in%20my%20excel%3F%3C%2FLINGO-BODY%3E
Occasional Contributor

I have a set of X and Y, as below.

XY
0.050.28344174663489400
0.51.26762275157997000
13.43248288736777000
29.69228927203065000
3.519.16153253754330000
526.01969057665260000


In my computer trying Office 2013, 2016, and 2019, all the R square of the linear trend is 0.9886, while in my friends' computers, it's 0.9945. We used SAS and SPSS to calculate, which also showed R2=0.9945.

We set the intercept = 0.

 

Is anything wrong with my computer?

How can I fix it?

 

6 Replies

@linnan5945 

I get 0.9945 in Excel 2019 with your data.

S0515.png

What do you see if you open the attached workbook?

@linnan5945

 

I do not have the same Excel versions, but FWIW, I can see the same difference between the R^2 calculated with LINEST and the chart trendline.

 

See the image below.  Also see the Excel file; but caveat: you might get different results if the file is recalculated when you open it in another version of Excel.

 

I cannot offer a dispositive explanation at this time.

 

But the wikipage (click here) explains that there ``are several definitions of R2 that are only sometimes equivalent``.  One such difference is the calculation of the "correlation coefficient" (r) v. "coefficient of determination" (R).

 

However, IMHO, the wikipage is "confusing" (read: dubious). I would need more time to vet the information and to test its applicability to the difference that we see.

 

R2 zero intercept 2.jpg

 

 

Wow cool.
So how can I change the trendline to use LINEST result in my excel?

@linnan5945  wrote:  ``Wow cool``

 

I actually have more details to share.  I hope to post later.

 

-----

 

@linnan5945  wrote:  ``So how can I change the trendline to use LINEST result in my excel?``

 

We cannot.  All I can offer is a difficult work-around, that might not be satisfactory.

 

I would let the chart create the trendline label.  Then I would edit it and overwrite the chart R^2 with the LINEST R^2.  The trendline label is just a textbox.

 

You can calculate the LINEST R^2 with the following formula (normally-entered), if you wish:

 

=INDEX(LINEST(B2:B7, A2:A7, FALSE, TRUE), 3, 1)

best response confirmed by allyreckerman (Microsoft)
Solution

Tying up loose ends for posterity....

 

@linnan5945  wrote: ``In my computer trying Office 2013, 2016, and 2019, all the R square of the linear trend is 0.9886, while in my friends' computers, it's 0.9945. We used SAS and SPSS to calculate, which also showed R2=0.9945. We set the intercept = 0.``

 

I wrote: ``the [coefficient of determination] wikipage (click here) explains that there "are several definitions of R^2 that are only sometimes equivalent". One such difference is the calculation of the "correlation coefficient" (r) v. "coefficient of determination" (R).``

 

That is, indeed, the reason for the difference, to a degree.

 

Excel RSQ calculates the square of the Pearson correlation coefficient (Excel PEARSON).

 

But LINEST R^2 and the linear trendline R^2 are based on the coefficient of determination (CoD).

 

When "zero intercept" is not specified -- that is, when there is a non-zero intercept -- all 3 statistics are the same, within the limits of floating-point arithmetic.

 

But when "zero intercept" is specified -- that is, when there is no intercept -- CoD differs from the Excel RSQ.

 

And more to the point, there is some debate among statisticians about how to calculate the CoD when a zero intercept is specified.

 

First, note that LINEST R^2 and the linear trendline R^2 are __not__ the square of any number, whereas Excel RSQ is. "R^2" is simply the notation that statisticians use for the CoD. I will use the term "CoD" (duh!) to avoid confusion.

 

The distinction is significant because the general method of calculating the CoD can result in __negative__ values for "R^2", whereas Excel RSQ is always non-negative.

 

The negative "R^2" (CoD) might seem like an error, because the square of any real number cannot be negative. But it is not an error, for the very reason that the CoD is not the square of any number.

 

Nevertheless, some statiscians justify the alternative method of calculating the CoD, in part, in order to avoid the negative CoD.

 

The method of calculating Excel RSQ is described in the RSQ help page (click here).

 

The methods of calculating the CoD is described in the LINEST help page (click here)

 

In general, the CoD is calculated by the formula 1 - SSres/SStot, or equivalently SSreg/SStot. SStot is Sigma((Y - avgY)^2), where "Y" is the original data.

 

That formula is always used to calculate the linear trendline R^2, at least in Excel 2010 (which I use) and in 2013, 2016 and 2019 (according to you).

 

That formula is also used to calculate LINEST R^2 when "zero intercept" is not specified (const = TRUE).

 

However, when "zero intercept" is specified (const = FALSE), LINEST calculates SStot differently, namely: Sigma(Y^2).

 

An explanation of that formula can be found in an academic article (click here), which is a heavy read (i.e. TMI).

 

That is why LINEST R^2 and the linear trendline R^2 differ in Excel 2010, 2013, 2016 and 2019, among others(?).

 

However, I am told that in Office 365 Excel, the calculation of the linear trendline R^2 has been changed to agree with LINEST R^2 when "zero intercept" is specified.

 

So for Office 365 users, the two values of "R^2" (CoD) should be the same, within the limits of floating-point arithmetic.

 

-----

 

From the "coefficient of determination" wikipage....

 

wiki coeff of determ defn.jpg

 

From the LINEST help page ....

 

linest r2 defn 2.jpg

 

From the RSQ help page....

 

excel rsq defn.jpg

 

@Joe User 

This is brilliant.

Now I understand why they are different and find the way to figure it out.

You totally answered my questions and solved my problems.

Thank you so so so so so much.