Page **2** of **3**

### Re: Smoothing splines (clamped spline)

Posted: **July 22nd, 2019, 2:24 am**

by **Petipace**

You could take a look at

http://www.netlib.org/dierckx/.

concur.f implements the clamped smoothing spline.

Disclaimer: I haven’t used this library myself, but Dierckx’s book is quite good.

### Re: Smoothing splines (clamped spline)

Posted: **July 22nd, 2019, 5:28 am**

by **Alan**

You could take a look at

http://www.netlib.org/dierckx/.

concur.f implements the clamped smoothing spline.

Disclaimer: I haven’t used this library myself, but Dierckx’s book is quite good.

Thank you -- it looks like Dierckx's book may indeed have what I am searching for -- ordered a decently priced used copy.

### Re: Smoothing splines (clamped spline)

Posted: **July 22nd, 2019, 12:55 pm**

by **Cuchulainn**

### Re: Smoothing splines (clamped spline)

Posted: **July 22nd, 2019, 5:13 pm**

by **FaridMoussaoui**

That's package was removed from CRAN repos. Orphaned and archived on 2014.

It was mainly a call to the fortran librairies.

### Re: Smoothing splines (clamped spline)

Posted: **July 22nd, 2019, 7:30 pm**

by **Cuchulainn**

That's package was removed from CRAN repos. Orphaned and archived on 2014.

It was mainly a call to the fortran librairies.

All that work for nothing?

### Re: Smoothing splines (clamped spline)

Posted: **July 22nd, 2019, 9:13 pm**

by **FaridMoussaoui**

It means it is not actively maintained but it is still there. I even installed it for a test and it's working (you need a fortran compiler).

### Re: Smoothing splines (clamped spline)

Posted: **September 13th, 2019, 1:08 pm**

by **Cuchulainn**

This might be useful; in particular, estimation of the smoothing parameter [$]\lambda[$].

### Re: Smoothing splines (clamped spline)

Posted: **September 13th, 2019, 1:39 pm**

by **Cuchulainn**

Hi Daniel,

Thank you for the code. I haven't opened it yet. Let me know if I will find the solution to the following problem, which will answer your question.

I want to find the piecewise cubic polynomial [$]g(t)[$] that solves the following problem:

(*) minimize [$] \left( \sum_{i=1}^n \{ y_i - g(t_i) \}^2 + \lambda \int_a^b \{ g''(u) \}^2 \, du \right)[$],

subject to

(A) given values for [$]g'(a)[$] and [$]g'(b)[$], where [$] a < t_1 < t_2 < \cdots < t_n < b[$],

(B) given data [$]\{t_i,y_i\}[$] and

(C) given [$]\lambda > 0[$], the 'smoothing' parameter.

Without (A), this is the

standard smoothing spline problem, solved by Reinsch (1967) (fulltext

here) and with many subsequent treatments.

BTW, I've got your 2018 book. Correct me if I'm wrong, but it looks like the cubic splines discussed there are just *interpolating* splines; i.e., the solution to (*) when [$]\lambda=0[$]?

.

Alan,

Don't suppose you have a numeric example for this?

### Re: Smoothing splines (clamped spline)

Posted: **September 16th, 2019, 5:53 pm**

by **Alan**

Daniel, Thanks for the book link. Sorry, don't have a good numerical example because I abandoned this approach for another. But, may get back to it.

### Re: Smoothing splines (clamped spline)

Posted: **September 16th, 2019, 8:19 pm**

by **Paul**

What's the underlying (financial?) problem? It looks a bit like something my friend Jesse Jones was working years ago. I don't think it went anywhere, but it was a brilliant idea!

### Re: Smoothing splines (clamped spline)

Posted: **September 16th, 2019, 9:22 pm**

by **Alan**

The problem is finding a risk neutral density from option quotes. The spline approach which I abandoned was: fit a smoothing spline to option smile data, with given derivative endpoints. The purpose of the derivatives, as opposed to so-called 'natural' boundary conditions, was to be improved extrapolation to small and large strikes.

### Re: Smoothing splines (clamped spline)

Posted: **September 16th, 2019, 9:35 pm**

by **Paul**

Ok, completely different problem! Jesse's was forward rate curve stuff.

### Re: Smoothing splines (clamped spline)

Posted: **September 19th, 2019, 2:01 pm**

by **Cuchulainn**

The problem is finding a risk neutral density from option quotes. The spline approach which I abandoned was: fit a smoothing spline to option smile data, with given derivative endpoints. The purpose of the derivatives, as opposed to so-called 'natural' boundary conditions, was to be improved extrapolation to small and large strikes.

I see. I would be pleasantly surprised if (any kind of) splines would work in this case (arbitrage, overshoot, extrapolation very scary, need C2 differentiability, all well known).

here is my (non-tested) idea:

If I have understood, you want to estimate the pdf from a finite data sample? In that case, kernel density estimation is used. So, the kd estimator coincides with the characteristic function (CF) and then use the Levy Inversion Formula to recover the pdf from CF. This can be easily done in Python (or MM I reckon as well). I suspect a key element is to find a good free parameter that fine-tunes extrapolation.

### Re: Smoothing splines (clamped spline)

Posted: **September 20th, 2019, 2:46 pm**

by **Alan**

The data sample is not draws from a pdf, but option prices.

However you approach the problem, you have to tackle the issue of extrapolation (of the risk-neutral pdf) to non-marketed strikes.

Anyway, I am close to finishing a write-up for a larger problem (which contains this risk-neutral density estimation as a sub-problem). Will announce it once I get it posted -- rather than pre-empting myself here.

If I ever return to this spline approach, all the responses here to that were quite helpful -- thanks to all!

### Re: Smoothing splines (clamped spline)

Posted: **September 22nd, 2019, 10:28 am**

by **Cuchulainn**

The data sample is not draws from a pdf, but option prices.

However you approach the problem, you have to tackle the issue of extrapolation (of the risk-neutral pdf) to non-marketed strikes.

Good point. Does this mean that kernel functions are not 'suitable' for data with no discernible underlying density? I need to think a bit more about this. It might be the wrong solution for the wrong problem.

This article does discuss a related problem it seems and authors are using slice kernel for interpolation and even a reference to extrapolation.

https://mathfinance.com/wp-content/uplo ... elling.pdf