Polynomial Regression

polynomial regression where x = day, y = cost

polynomial regression degrees 2-4
Method
The polynomial regression can be generated by the RDOUBLE formula below.
The function in the example below is for a polynomial regression of the third degree.
If you require a function of a different degree, simply edit the 3 in the poly function to whichever degree you need.
Formulation
To keep this approach generalized, I did not convert the values to a time series (ts). Instead, I used the rank function to convert each x-axis element to a vector of 1-n by using the RANK function.
rdouble(FALSE, "
x <- args[[2]];
y <- args[[1]];
model <- lm(y ~ poly(x, 3));
predict(model);
", [Total Cost], rank(max([Months in Date]), "ASC", "1223"))
Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022