polynomial regression where x = day, y = cost
polynomial regression degrees 2-4
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.
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.
x <- args[];
y <- args[];
model <- lm(y ~ poly(x, 3));
", [Total Cost], rank(max([Months in Date]), "ASC", "1223"))