Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
B = Y Intercept
I used the two functions slope and Intercept but for some
reason the intercept is coming out wrong. Here is the code... Slope = Application.WorksheetFunction.Slope(Range ("e25:e28"), Range("c25:c28")) Intercept = Application.WorksheetFunction.Intercept(Range ("e25:e28"), Range("c25:c28")) The label on the graph shows y = 14484x + 562698 and so my code should produce the same results but it doesn't... My slope is 14483.664 (good) My intercept is -28390146.1562596 (bad) should be 562698 Thoughts?: The 0nly thing I can think of is that the values in the "c" range are 2000,2001,2002,2003 and somehow my answer is the Y intercept at the year 0???? Or maybe the datatypes are causing a bad answer..one cell range has the Excel 'Number' datatype and the other cell range is the Excel 'Currency' datatype Please advise Alex. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
B = Y Intercept
My guess is that your graph is a "Line" chart instead of an "XY
(Scatter)" chart. If so, then the VBA intercept is correct because the graph equation is based on the assumption that the X data is 1,2,3,4 (2000,2001,2002,2003 are just x labels, not x values in a "Line" chart). Jerry Alex A wrote: I used the two functions slope and Intercept but for some reason the intercept is coming out wrong. Here is the code... Slope = Application.WorksheetFunction.Slope(Range ("e25:e28"), Range("c25:c28")) Intercept = Application.WorksheetFunction.Intercept(Range ("e25:e28"), Range("c25:c28")) The label on the graph shows y = 14484x + 562698 and so my code should produce the same results but it doesn't... My slope is 14483.664 (good) My intercept is -28390146.1562596 (bad) should be 562698 Thoughts?: The 0nly thing I can think of is that the values in the "c" range are 2000,2001,2002,2003 and somehow my answer is the Y intercept at the year 0???? Or maybe the datatypes are causing a bad answer..one cell range has the Excel 'Number' datatype and the other cell range is the Excel 'Currency' datatype Please advise Alex. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I force the y-intercept value | Excel Worksheet Functions | |||
Regression with zero intercept | Excel Worksheet Functions | |||
regression using set intercept | Excel Discussion (Misc queries) | |||
Regression intercept to 0 | Excel Worksheet Functions | |||
Intercept and Indirect | Excel Worksheet Functions |