LINEST vs. Trendline (on graph)

espevak

New Member
Joined
Apr 30, 2009
Messages
4
Has anyone seen this before? If so, how do I work around it?

I've been quite happy using both linest and the trendline functions. However, I've found a very odd behavior when forcing the intercept to zero.

I'm currently fitting a second order polynomial (with and without the zero intercept). Here is what I'm currently seeing when using an intercept of zero (FALSE for "const" in LINEST):

Excel 2007:
The second order term in the trendline equation is incorrect -- it's the same coefficient as the non-zero intercept case -- though LINEST appears to come up with the proper coefficient. However, LINEST comes up with the wrong R^2 term (it shows a higher R^2 with a forced zero intercept).

(A side issue with Excel 2007 seems to be when showing the equation for a zero intercept case, the second order coefficient will often disappear which I suppose isn't so bad since that coefficient is incorrect anyway...)

Excel 2003:
The trendline coefficient on the graph are correct but the LINEST R^2 is still incorrect.

Thank you.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Using XL 2007 I found that the trend line coefficients and Linest values were the same, both with the Y intercept set to 0 and calculated. Could you post some data where you got different results?

I did find that the R^2 value was different in Linest and the trend line when the intercept was set to zero though, and for Linest the R^2 increased when the intercept was 0. I'm not a statistician, and I don't have time at the moment to investigate this further at the moment, but I would be interested to hear comments from others.
 
Upvote 0
Further to my previous post, checking the R^2 values using the definition given here:

http://en.wikipedia.org/wiki/Coefficient_of_determination

it seems that the trend line value is correct (or at least agrees with the Wikipedia definition), and the Linest value is different when the intercept with the Y axis is set to zero.

Any statisticians out there who can comment on what is going on?
 
Upvote 0
I think I have found the answer.

This site:

http://www.curvefit.com/linear_regression.htm

gives a nice easy to understand explanation of how R^2 is calculated and why.

It has this to say about calculating R^2 for a line constrained to pass through the origin:

"Why Prism doesn't report r2 in constrained linear regression

Prism does not report r2 when you force the line through the origin (or any other point), because the calculations would be ambiguous. There are two ways to compute r2 when the regression line is constrained. As you saw in the previous section, r2 is computed by comparing the sum-of-squares from the regression line with the sum-of-squares from a model defined by the null hypothesis. With constrained regression, there are two possible null hypotheses. One is a horizontal line through the mean of all Y values. But this line doesn't follow the constraint -- it does not go through the origin. The other null hypothesis would be a horizontal line through the origin, far from most of the data.

Because r2 is ambiguous in constrained linear regression, Prism doesn't report it. If you really want to know a value for r2, use nonlinear regression to fit your data to the equation Y=slope*X. Prism will report r2 defined the first way (comparing regression sum-of-squares to the sum-of-squares from a horizontal line at the mean Y value)."

Now it seems that the Excel (and Gnumeric) Linest() function uses the second hypothesis for a constrained regression line, resulting in a higher R^2 value, compared with the unconstrained line. The chart trend line function on the other hand seems to use the first hypothesis.

So both results are valid.

It would have been nice if Microsoft could have explained that.

The remaining question is why espevak was getting incorrect coefficients from the chart trendline. I can't reproduce that behaviour, so I can't comment.
 
Upvote 0
Thanks for posting the observation. I can confirm what DougJ saw; in Excel 2007 I am getting the same equation coefficients between LINEST and Trendline for a 2nd-order polynomial forced through zero, but the correlation coefficients are different.

Microsoft claimed to have fixed some LINEST problems (including incorrect correlation coefficients) in Excel 2003 and later versions: see http://support.microsoft.com/kb/828533
; but perhaps they didn't spot this remaining discrepancy between Trendline and LINEST.

I also don't know what to make of the statement at the Microsoft site that says "In Excel 2003 and in later versions of Excel, these problems have been addressed, except for non-linear regression, caused by an issue with the Solver add-in instead of with the statistical functions or the Analysis ToolPak."

Does this mean that my 2nd-order polynomial fit from Excel may not be correct after all?
 
Upvote 0
Gnumeric

Help. All my .xlsx workbooks have suddenly become Gnumeric. If I open a file using MS Excel 2007 and re-save it, it is saved as a gnumeric file. Even old files I haven't looked at, have become gnumeric. What can I do?
 
Upvote 0
Sandy - posting your question in a more appropriate thread would probably be a good start!

Try checking the File Save as option under Office Blob - Excel Options - Save.

If this has been set to Gnumeric, reset it to whichever Excel version you want.

One other thought, have you recently installed Gnumeric? If so it is possible that the file assocoation for XL files has been set to gnumeric, but the files are still Excel files. Have you tried opening them in Excel?
 
Upvote 0
Hi, This is my first question ever in this forum. Here it goes.
Iam using excel 2010, I am using the trendline within a plot to fit a 3rd degree polynomial, since I needed to obtain the standard errors for the coefficients I used the linest function to get all the stuff not just the coefficients, but what a surprise to get a completely different set of estimates!! Does anyone have any idea/information of how these estimates are obtained in excel? I also used the R language to obtain the estimates, just using the regular matrix algebra strategy for linear regression and I can say both results in excel are different from the matrix algebra solution. The dataset I am using is:
y
x
6.560
59.65835
6.686
59.66345
6.836
59.66855
7.001
59.67366
7.172
59.67875
7.335
59.68385
7.482
59.68895

<TBODY>
</TBODY>

The estimates I got using the polynomial trendline are:
-13179.71092359528.06-1408066122800912846

<COLGROUP><COL style="WIDTH: 60pt" span=4 width=80><TBODY>
</TBODY>

and the estimates I got using the linest function are:
0.930422693-83.0244196097942.59514

<TBODY>
</TBODY>


Thanks in advance.


<TBODY>
</TBODY><COLGROUP><COL><COL><COL><COL></COLGROUP>
 
Last edited:
Upvote 0
With both Linest and a cubic trend line I get:
0.01637626, -0.347776298, 2.491393835, 53.65787319

Linest reports an R^2 value of 0.999991572, and the trend line reports 0.999988877055

The Linest formula was: =LINEST(YRange,XRange^{1,2,3},,TRUE)

Excel 2013
 
Upvote 0
LINEST and trendlines use different methods. What's your question?
 
Upvote 0

Forum statistics

Threads
1,215,824
Messages
6,127,107
Members
449,358
Latest member
Snowinx

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