Cubic Spline functions

Discussion in 'CS2' started by Molly, Aug 11, 2022.

  1. Molly

    Molly Ton up Member

    Hi guys,

    Please could someone explain the process of using a cubic spline function - question 3 in the chapter 12 questions has confused me - seems like theyve just added on sum(theta_j beta_j), but i don't understand the thought behind this:

    i thought the cubic spline was f(x)=alpha_0+alpha_1x+ sum(theta_j beta_j) - where has the first part of this gone?
    Thanks,
    Molly
     
  2. Andrew Martin

    Andrew Martin ActEd Tutor Staff Member

    Hi Molly

    Thanks for pointing this out, I agree that the Bj as given in this solution don't look right. In general, the Bj are meant to represent a set of basis functions for cubic splines. If we have a set of basis functions over a particular set of knots, what this means is that any cubic spline with these knots can be represented as a linear combination of these functions. So, for any cubic spline, we can write it as:

    \( \theta_1 B_1(x) + \theta_2 B_2(x) + ... + \theta_j B_j(x) \)

    For some values of the parameters \( \theta_1, \theta_2, ..., \theta_j \)

    An example set of basis functions for cubic splines is the set of functions:

    \( \{ 1, x, x^2, x^3, \phi_1(x), \phi_2(x) ..., \phi_n(x) \} \)

    where:

    \( \phi_i(x) = 0 \enspace \enspace \enspace \enspace \enspace \enspace \enspace \enspace \enspace \enspace if \enspace \enspace x < x_i \)
    \( \enspace \enspace \enspace \enspace \enspace \enspace \enspace (x - x_i)^3 \enspace \enspace \enspace if \enspace \enspace x >= x_i \)

    ie, we can write any cubic spline with the given knots as:

    \( \alpha_0 + \alpha_1 x + \alpha_2 x^2 + \alpha_3 x ^ 3 + \beta_1 \phi_1(x) + \beta_2 \phi_2(x) + ... + \beta_n \phi_n(x) \)

    For some values of the parameters \( \alpha_0, \alpha_1, \alpha_2, \alpha_3, \beta_1, \beta_2, ..., \beta_n \). In this case, using the notation above, we would have \( B_1(x) = 1 \) and \(B_2(x) = x \) and so on.

    There are other sets of functions that are also bases for cubic splines. Specifically the \( B_j(x) \) are actually typically used to represent a set of basis splines (ie where the basis functions themselves are actually splines) so in general we can just use \( B_j(x) \) to represent some basis.

    For natural cubic splines, we have the constraint that they are linear prior to the first knot and after the last knot. These constraints actually mean we need fewer functions in our basis. An example basis for natural cubic splines is the set of functions presented in Chapter 11:

    \( \{ {1, x, \Phi_1(x), \Phi_2(x) ..., \Phi_{n-2}(x)} \} \)

    where, for example, we've lost the \( x^2 \) and \( x^3 \) because we know we must have linearity prior to the first knot. What this means is that any natural cubic splines over the given set of knots can be written as a linear expression of these functions. When we do cubic spline graduation we are trying to find the parameters in that linear expression that give us a natural cubic spline that fits the mortality data well.

    So I think the solution should just say:

    The model is:

    \( ln[E(D_{x,t}] = ln E_{x,t}^c + \sum_{j = 1}^{J} \theta_j B_j(x) \)

    where \( B_j(x) \) is some cubic spline basis.

    Hope this helps!

    Andy
     
    Molly likes this.
  3. Molly

    Molly Ton up Member

    Hi Andy,

    this is great, thank you so much, really appreciate how clear you have made this - was definitely an area that was worrying me, so thanks alot!!! :)
     

Share This Page