A
Alex A
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:
'Variables
x1 = IVSLH2Range.Row + 1
x2 = IVSLH2Range.Row + intRowCountIVSLH2 - 2
'Coefficients
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(Cells
(x1, 5), Cells(x2, 5)), Range(Cells(x1, 1), Cells(x2, 1)))
'Solve for Y
y = m * x + b
Now, solving for Y with a second degree polynomial
equation involves:
y = (c2 * x^2) + (c1 * x ^1) + b
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.)
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:
'Variables
x1 = IVSLH2Range.Row + 1
x2 = IVSLH2Range.Row + intRowCountIVSLH2 - 2
'Coefficients
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(Cells
(x1, 5), Cells(x2, 5)), Range(Cells(x1, 1), Cells(x2, 1)))
'Solve for Y
y = m * x + b
Now, solving for Y with a second degree polynomial
equation involves:
y = (c2 * x^2) + (c1 * x ^1) + b
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.)