TABLE OF CONTENTS


splineUtils/splinederivint [ Functions ]

NAME

    splinederivint --- compute the convolution of the derivatives of two spline bases

FUNCTION

Used to compute the penalty matrix for the integrated squared second derivative. This routine computes the integral from 0 to infinity of the l1 derivative and the l2 derivative of the j1 and j2-th splines of order n1 and n2 defined on a set of knots. For instance, in order to compute the [j1,j2] entry of the penalty matrix, the function makePenalty.2deriv calls

       out[j1, j2] <- splinederivint(2, ord, j1, 2, ord, j2, knots)

SYNOPSIS

1627 splinederivint <- function(l1, n1, j1, l2, n2, j2, knots)

INPUTS

    l1     derivative of the first spline
    n1     order of the first spline
    j1     index of the first spline
    l2     derivative of the second spline
    n2     order of the second spline
    j2     index of the second spline
    knots  set of knots on which the splines are defined

OUTPUTS

    a double containing the convolution of the derivatives of two basis functions

SOURCE

1630 {
1631     # if they don't overlap, the integral is 0
1632     if(j1 - n1 >= j2 | j2 - n2 >= j1) return(0)
1633     # For the 0th derivatives, use the regular convolution method
1634     if(l1 == 0 & l2 == 0) return(splineconv(0, n2, j1, n2, j2, knots))
1635     # symmetry
1636     if(l2 > l1){
1637         l3 <- l1; l1 <- l2; l2 <- l3
1638         n3 <- n1; n1 <- n2; n2 <- n3
1639         j3 <- j1; j1 <- j2; j2 <- j3
1640     }
1641     out <- 0
1642     # recursive method to step-by-step reduce this problem to a regular convolution problem
1643     denom1 <- knots[ki(knots, j1 - 1)] - knots[ki(knots, j1 - n1)]
1644     denom2 <- knots[ki(knots, j1)] - knots[ki(knots, j1 - n1 + 1)]
1645     if(denom1 > 0) out <- out + (n1 - 1) / denom1 *
1646         splinederivint(l1 - 1, n1 - 1, j1 - 1, l2, n2, j2, knots)
1647     if(denom2 > 0) out <- out - (n1 - 1) / denom2 *
1648         splinederivint(l1 - 1, n1 - 1, j1, l2, n2, j2, knots)
1649     return(out)
1650 }