cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
widget_5d4399e9cec8dc2e6806b92e__1_.png
polynomial regression where x = day, y = cost
widget_5d4399e9cec8dc2e6806b92e__2_.png
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"))
Rate this article:
Version history
Last update:
‎03-02-2023 08:27 AM
Updated by:
Contributors