Kung Foo Masters Only
Ale
A couple of options
1) If you have the graph with the equation, then you can grab the equation, parse it to get the variables and progress. The following should give you the idea from the graph
Sub aaa(
aa = ActiveSheet.ChartObjects(1).Chart.SeriesCollection (1).Trendlines(1).DataLabel.Tex
c1start = InStr(1, aa, "=", 1) +
x2start = InStr(1, aa, "x2", 1
xstart = InStr(x2start + 1, aa, "x", 1
c1 = Mid(aa, c1start, x2start - c1start
c2 = Mid(aa, x2start + 2, xstart - x2start - 2
b = Mid(aa, xstart + 1
'MsgBox c
'MsgBox c
'MsgBox
MsgBox c1 * 2 ^ 2 + c2 * 2 +
End Su
2) If you use the standard 1,2,3... as one variable and 1,4,9 as a second (ie they are x and x^2) then you can again use LINEST to get the variables in the way that you have done
Ton
----- Alex A wrote: ----
Whoever can answer this one is the Master. I have
successfully solved for and used the coefficients of a
trendline through VBA and formulated the linear
regression one period forward. Now I want to do the same
thing with a second order polynomial trendline
Solving for Y with the linear equation went like this
'Variable
x1 = IVSLH2Range.Row +
x2 = IVSLH2Range.Row + intRowCountIVSLH2 -
'Coefficient
m = Application.WorksheetFunction.Slope(Range(Cells(x1 ,
5), Cells(x2, 5)), Range(Cells(x1, 1), Cells(x2, 1))
x = (Year(Date) + 1 - 2000
b = Application.WorksheetFunction.Intercept(Range(Cell
(x1, 5), Cells(x2, 5)), Range(Cells(x1, 1), Cells(x2, 1))
'Solve for
y = m * x +
Now, solving for Y with a second degree polynomial
equation involves
y = (c2 * x^2) + (c1 * x ^1) +
But I need to be able to solve for c1, c2, and b. This
is where I am not sure how to proceed. And if I do how
do I get VBA to crunch that equation
How do I interpret this???
c2: =INDEX(LINEST(y,x^{1,2}),1
C1: =INDEX(LINEST(y,x^{1,2}),1,2
b = =INDEX(LINEST(y,x^{1,2}),1,3
(Thanks to John Walkenbach and an anonymous user that got
me this far.
|