4 CHAPTER 1.NONPARAMETRIC REGRESSION Note that if we try to fit such a function to data of the form (1,1),(x2,22),...(n,Un), we require at least one x value between any pair of knots (which include a and b,the so- called 'Boundary knots')in order to obtain a full-rank model matrix.This is required for invertibility of the normal equations.Note,as well,that the columns of the model matrix are orthogonal which implies that this least-squares problem is now very well conditioned. The reason for the orthogonality is that the regions where the functions are non-zero do not overlap;each basis function is non-zero only on a single interval of the form [ti,. Finally,observe that the size of this basis is the same as the truncated power basis,so we are requiring the same numbers of degrees of freedom. Moving to the piecewise linear case,we note first that the piecewise constant B- splines could be obtained from their truncated counterparts by differencing.Two levels of differencing applied to the truncated linear functions on [a,b with knots at t1,...,t gives a set of continuous piecewise linear functions Bi(r)which are non-zero on intervals of the form [ti,t+2.These functions are called or hat'or'chapeau'functions.They are not orthogonal,but since Bi(x)is nonzero only with B:-1.1()and B+1.1(),the resulting model matrix used in computing the least-squares regression estimates is well-conditioned. The more usual way of computing the linear B-spline sequence is through the formula B1(x)= 二12e回+2二1e1@,i=-1,2,k(1.3) tit1-ti tit2-ti+l By taking t-1=to a and t+1=b,we can use the above formula to compute B-1.1() and Bo.1(x),B-1,1(x)and B.1(x),for t a,b,using the convention that 0x oo =0. In total,this gives us k +2 basis functions for continuous piecewise linear splines.For the case of knots at.3 and.6 and boundary knots at 0 and 1,these functions are plotted in Figure 1.1.Note that,with two knots,there are 4 basis functions.The middle two have the 'hat'shape,while the first and last are 'incomplete'hats.Note that because the B-splines are nonzero on at most the union of two neighbouring inter-knot subintervals, some pairs of B-splines are mutually orthogonal. ITo obtain the plot,type x <-seq(0,1,length=50) matplot(x,bs(x,knots=c(.3,.6),intercept=TRUE,degree=1)[,1:4], type="1")4 CHAPTER 1. NONPARAMETRIC REGRESSION Note that if we try to fit such a function to data of the form (x1, y1),(x2, y2), . . .(xn, yn), we require at least one x value between any pair of knots (which include a and b, the socalled ‘Boundary knots’) in order to obtain a full-rank model matrix. This is required for invertibility of the normal equations. Note, as well, that the columns of the model matrix are orthogonal which implies that this least-squares problem is now very well conditioned. The reason for the orthogonality is that the regions where the functions are non-zero do not overlap; each basis function is non-zero only on a single interval of the form [ti , ti+1]. Finally, observe that the size of this basis is the same as the truncated power basis, so we are requiring the same numbers of degrees of freedom. Moving to the piecewise linear case, we note first that the piecewise constant Bsplines could be obtained from their truncated counterparts by differencing. Two levels of differencing applied to the truncated linear functions on [a, b] with knots at t1, . . . , tk gives a set of continuous piecewise linear functions Bi,1(x) which are non-zero on intervals of the form [ti , ti+2]. These functions are called or ‘hat’ or ‘chapeau’ functions. They are not orthogonal, but since Bi,1(x) is nonzero only with Bi−1,1(x) and Bi+1,1(x), the resulting model matrix used in computing the least-squares regression estimates is well-conditioned. The more usual way of computing the linear B-spline sequence is through the formula Bi,1(x) = (x − ti) ti+1 − ti 1x∈[ti,ti+1)(x) + (ti+2 − x) ti+2 − ti+1 1x∈[ti+1,ti+2)(x), i = −1, 2, . . . , k (1.3) By taking t−1 = t0 = a and tk+1 = b, we can use the above formula to compute B−1,1(x) and B0,1(x), Bk−1,1(x) and Bk,1(x), for x ∈ [a, b], using the convention that 0 × ∞ = 0. In total, this gives us k + 2 basis functions for continuous piecewise linear splines. For the case of knots at .3 and .6 and boundary knots at 0 and 1, these functions are plotted in Figure 1.1.1 Note that, with two knots, there are 4 basis functions. The middle two have the ‘hat’ shape, while the first and last are ‘incomplete’ hats. Note that because the B-splines are nonzero on at most the union of two neighbouring inter-knot subintervals, some pairs of B-splines are mutually orthogonal. 1To obtain the plot, type x <- seq(0, 1, length=50) matplot(x, bs(x, knots=c(.3, .6), intercept=TRUE, degree=1)[, 1:4], type="l")