cancel
Showing results for
Did you mean:

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Cubic Spline Interpolation

Atom

Hi - I am trying to interpolate points on a yield curve using Cubic Spline Interpolation.

I have VBA code that does this, but am having trouble finding an intuitive way to convert this to Alteryx.

Two questions:

1. Is there a way to get what I need from the "Spline Model" tool? I played with it for a bit, but it did not seem to be what I need.

2. What would be the logical way to use matrices to solve for the required coefficients? I'm having trouble seeing a way to make a matrix that is dynamic in size depending on the number of inputs, and then how to do the linear algebra required to solve for the coefficients.

Any other suggestions on how to execute?

Thank you! Nebula

Interesting challenge.

I think the easiest way would be to use the R tools to get a cubic spline fit out.

The more challenging way would be to reproduce the spline computation within Alteryx.  I can easily see how to do with the SDKs but reckon also do able with the core toolset.

Do you have any sample data (and results) you can post?

Atom

You are right - and I was able to write some code in R (with very limited R experience) to complete it. However, if you were looking for a fun project I would be interested to see if it could be done with tools in Alteryx..!

See attached excel for sample input and output.

-------------------------------

The R code that was able to produce this is:

-------------------------------

my.dataset <- read.Alteryx("#1", mode="data.frame")
limits <- read.Alteryx("#2", mode="data.frame")
x <- my.dataset[,1]
y <- my.dataset[,2]
minx <- limits[,1]
maxx <- limits[,2]
n <- limits[,4]

output <- spline(x, y, n, method = "fmm",
xmin = minx, xmax = maxx)
output <- as.data.frame(output)

Labels