R2 value inconsistent between graph and linest function

LML

New Member
Joined
Mar 16, 2010
Messages
2
For a data correlation, I have added a trendline to the plotted data with R2, and also used the linest function on the same data.

The two R2 values match when there is an intercept, but when the correlation is forced through the origin the R2 values differ by up to 2%.

Any ideas why this is? I'm inclined to believe the graph R2 as this is slightly lower when forced through the origin, whereas the linest R2 is higher.

Cheers
 
Louise,

In case you want to recheck, or ever do regressions etc again, you can use this VBA code if you'd like an alternative to LinEst.

Just put your dependent variable data in columnA (with no header), and your independent (or regressor) variables in columns B and C and ... (however many you want to use).

Then just run the code.
Code:
Sub regression()
Dim a As Range, n As Long, m As Long
Dim y, x, gg
Dim coeff, Rsq As Single

Set a = Range("A1").CurrentRegion
n = a.Rows.Count: m = a.Columns.Count
Cells(1, m + 1).Resize(n) = 1
y = a.Resize(, 1)
x = a.Resize(, m).Offset(, 1)
Cells(1, m + 1).Resize(n).ClearContents

With Application
    gg = .MInverse(.MMult(.Transpose(x), x))
    coeff = .MMult(gg, .MMult(.Transpose(x), y))
    Rsq = Evaluate(.MMult(.Transpose(y), .MMult(x, coeff))) / .SumSq(y)
End With

'Outputs follow
Cells(1, m + 3) = "Coeffs"
Cells(2, m + 3).Resize(m) = coeff
Cells(1, m + 4) = "RSq"
Cells(2, m + 4) = Rsq
End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top