![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Apr 2009
Posts: 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. |
|
|
|
|
|
#2 |
|
Join Date: Jan 2007
Location: Australia
Posts: 21
|
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. |
|
|
|
|
|
#3 |
|
Join Date: Jan 2007
Location: Australia
Posts: 21
|
Further to my previous post, checking the R^2 values using the definition given here:
http://en.wikipedia.org/wiki/Coeffic..._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? |
|
|
|
|
|
#4 |
|
Join Date: Jan 2007
Location: Australia
Posts: 21
|
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. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|