splineDesign             package:splines             R Documentation

_D_e_s_i_g_n _M_a_t_r_i_x _f_o_r _B-_s_p_l_i_n_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Evaluate the design matrix for the B-splines defined by 'knots' at
     the values in 'x'.

_U_s_a_g_e:

     splineDesign(knots, x, ord = 4, derivs, outer.ok = FALSE)
     spline.des(knots, x, ord = 4, derivs, outer.ok = FALSE)

_A_r_g_u_m_e_n_t_s:

   knots: a numeric vector of knot positions with non-decreasing
          values.

       x: a numeric vector of values at which to evaluate the B-spline
          functions or derivatives.  Unless 'outer.ok' is truee, the
          values in 'x' must be between 'knots[ord]' and 'knots[
          length(knots) + 1 - ord ]'.

     ord: a positive integer giving the order of the spline function.
          This is the number of coefficients in each piecewise
          polynomial segment, thus a cubic spline has order 4. 
          Defaults to 4.

  derivs: an integer vector of the same length as 'x' and with values
          between '0' and 'ord - 1'.  The derivative of the given order
          is evaluated at the 'x' positions.  Defaults to a vector of
          zeroes of the same length as 'x'.

outer.ok: logical indicating if 'x' should be allowed outside the
          _inner_ knots, see the 'x' argument.

_V_a_l_u_e:

     A matrix with 'length( x )' rows and 'length( knots ) - ord'
     columns.  The i'th row of the matrix contains the coefficients of
     the B-splines (or the indicated derivative of the B-splines)
     defined by the 'knot' vector and evaluated at the i'th value of
     'x'. Each B-spline is defined by a set of 'ord' successive knots
     so the total number of B-splines is 'length(knots)-ord'.

_N_o_t_e:

     The older 'spline.des' function takes the same arguments but
     returns a list with several components including 'knots', 'ord',
     'derivs', and 'design'.  The 'design' component is the same as the
     value of the 'splineDesign' function.

_A_u_t_h_o_r(_s):

     Douglas Bates and Bill Venables

_E_x_a_m_p_l_e_s:

     splineDesign(knots = 1:10, x = 4:7)

     knots <- c(1,1.8,3:5,6.5,7,8.1,9.2,10)# 10 => 10-4 = 6 Basis splines
     x <- seq(min(knots)-1, max(knots)+1, length=501)
     bb <- splineDesign(knots, x=x, outer.ok = TRUE)

     plot(range(x), c(0,1), type="n", xlab="x", ylab="",
          main= "B-splines - sum to 1 inside inner knots")
     mtext(expression(B[j](x) *"  and "* sum(B[j](x), j==1, 6)), adj=0)
     abline(v=knots, lty=3, col="light gray")
     abline(v=knots[c(4,length(knots)-3)], lty=3, col="gray10")
     lines(x, rowSums(bb), col="gray", lwd=2)
     matlines(x, bb, ylim = c(0,1), lty=1)

