Skip to article frontmatterSkip to article content

Splines

Let f(x)=xf(x)=\left|x\right|

Is ff piecewise linear?

Is ff a linear spline? Why or why not?

Is ff a cubic spline? Why or why not?

Linear splines, and a basis

Suppose ff is a linear spline. What conditions does it satisfy at its knots? What conditions does it satisfy between its knots?

Consider the space of all linear splines with a single knot at ξ1\xi_{1}. It is possible to create a three-dimensional basis for this space, i.e. a set of three functions h0,h1,h2h_0,h_1,h_2 such that any function in the space can be written as β0h0(x)+β1h1(x)+β2h2(x)\beta_0 h_0(x) + \beta_1 h_1(x) + \beta_2 h_2(x) for some suitable choice of coefficients βR3\beta \in \mathbb{R}^3. List three functions that, together, form such a basis.

Let f(x)=2x+I(x>0)x2f(x)=2x+\mathbb{I}(x>0)x^{2}

  1. Is its derivative continuous?

  2. Is it a cubic spline?

Let f(x)=I(x>0)x7f(x)=\mathbb{I}(x>0)x^{7}. Is it a cubic spline?

Write a linear spline

Give an example of a linear spline with three knots.

Let f(x)=I(x>4)(x4)3f(x)=\mathbb{I}(x>4)(x-4)^{3}. Is it a natural cubic spline?

Fourth derivatives for cubic splines

Let f(x)f(x) be a cubic spline with knots at 0 and 5. What is the fourth derivative of ff evaluated at 3, f(3)f''''(3)?

General question type

More generally, given any sort of piecewise-defined function,

f(x)={a1+b1x+c1x2+d1x3if x<ξ1a2+b2x+c2x2+d2x3if ξ1x<ξ2a3+b3x+c3x2+d3x3if ξ2xf(x)=\begin{cases} a_{1}+b_{1}x+c_{1}x^{2}+d_{1}x^{3} & \mathrm{if}\ x<\xi_{1}\\ a_{2}+b_{2}x+c_{2}x^{2}+d_{2}x^{3} & \mathrm{if}\ \xi_{1}\leq x<\xi_{2}\\ a_{3}+b_{3}x+c_{3}x^{2}+d_{3}x^{3} & \mathrm{if}\ \xi_{2}\leq x \end{cases}

we might ask you questions like

  1. it is a linear spline?

  2. is it a cubic spline?

  3. is it a natural cubic spline?

  4. is it continuous?

  5. is the first derivative of ff continuous?

  6. is the second derivative of ff continuous?

  7. are the pieces constant (true only if bi=ci=di=0b_{i}=c_{i}=d_{i}=0)?

  8. are the pieces linear (true only if ci=di=0c_{i}=d_{i}=0)?

  9. are the pieces quadratic (true only if di=0d_{i}=0)?

You’ll need to be able to calculate the answers to these questions in terms of the coefficients. Because the pieces are all polynomials, any derivative of these pieces themselves will be continuous (e.g., if f(x)f(x) is a cubic polynomial then every derivative of ff is continuous). So when you’re thinking about continuity of derivatives for piecewise polynomials, you really just have to check the knots.

Smoothing spline

Consider a dataset with p=12p=12 features and one numerical response for each of n=2000n=2000 data points. You would like to fit this data using a GAM, with a smoothing spline for each feature. Which of the following will be your biggest challenge?

a. Picking the right regularization strength for each feature.

b. Choosing the right number of knots for each feature.