Cubic Spline VBA code

jimmyvba

New Member
Joined
Jul 19, 2013
Messages
20
Hi Guys,

I have been searching the net for a piecewise cubic spline fitting vba code in which I can specify the knots in the curve. Does anyone have it available? I have had no luck finding it so far. All I get is cubic spline codes without having the flexibility to do it piecewise.

I am basically trying to fit the term structure of US interest rates using this interpolation method.

Thanks.
 
A further question, how do we calculate m (25 in this case).

If we want to have 1000 pairs then what would be m? the formula to calculate it?
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
how do we calculate m?

Code:
    ' y() contains (by definition) n + 1 points: y(0), y(1), ..., y(n)
    ' The n + 1 points define n segments.

    '   iType Description                        Points Returned
    '     1   Open (natural) spline              1 + m * n
    '     2   Closed spline w/o closing segment  1 + m * n
    '     3   Closed spline w/ closing segment   1 + m * (n + 1)
    '     4   Tangent spline                     1 + m * (n - 2)

Solve for m.
 
Upvote 0
m is the number of points you want on each segment.
 
Upvote 0
Hi

For the purpose of finding spline functions in VBA, I saw the code presented here and another code i this page: Excel Help for Gilt Curve

I appreciate it if you answer my question:


[FONT=&quot]I guess that these codes assume "zero value" for the second derivatives of the first and last points of the data which are needed as the boundary conditions. Am I right?

thanks[/FONT]
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top