We now have a finite number N of observations with which to determine the infinite-dimensional B(t). This is an impossible problem: it is almost always possible to find a B(t) so that (9.2) is satisfied with Ei = 0. More importantly, there are always an infinite number of possible regression coefficient functions B(t) that will produce exactly the same predictions yi. Even if we expand each functional covariate in terms of a limited number of basis functions, it is entirely possible that the total number of basis functions will exceed or at least approach N.
9.4 Three Estimates of the Regression Coefficient Predicting Annual Precipitation
Three strategies have been developed to deal with this underdetermination issue. The first two redefine the problem using a basis coefficient expansion of 0:
K
0(t) = £ Ck帆 t) = c0 Mt). (9.3)
k
The third replaces the potentially high-dimensional covariate functions by a low-dimensional approximation using principal components analysis. The first two ap-proaches will be illustrated using function fRegress. Function fRegress in R and Matlab requires at least three arguments:
yfdPar This object contains the response variable. It can be a functional param¬eter object, a functional data object, or simply a vector of N scalar responses. In this chapter we restrict ourselves to the scalar response situation.
xfdlist This object contains all the functional and scalar covariate functions used to predict the response using the linear model. Each covariate is an element or component in a list object in R or an entry in a cell array in Matlab.
betalist This is a list object in R or a cell array in Matlab of the same length as the second argument; it specifies the functional regression coefficient objects. Because it is possible that any or all of them can be subject to a roughness penalty, they are all in principle functional parameter objects, although fRegress will by default convert both functional data objects and basis objects into functional pa-rameter objects.
Here we store the two functional data covariates required for predicting log an-nual precipitation in a list of length two, which we here call templist, to be used for the argument xfdlist.
templist = vector("list",2)
templist[[1]] = rep(1,35)
templist[[2]] = tempfd
Notice that the intercept term is here set up as a constant function with 35 repli-cations.
9.4.1 Low-Dimensional Regression Coefficient Function p
The simplest strategy for estimating p is just to keep the dimensionality K of p in (9.3) small relative to N. In our test-bed expansion, we will work with five Fourier basis functions for the regression coefficient p multiplying the temperature profiles; we will also use a constant function for a, the multiplier of the constant intercept covariate set up above.
conbasis = create.constant.basis(c(0,365))
betabasis = create.fourier.basis(c(0,365),5) betalist = vector("list",2)
betalist[[1]] = conbasis
betalist[[2]] = betabasis
Now we can call function fRegress, which returns various results in a list object that we call fRegressList.
fRegressList = fRegress(annualprec,templist,betalist)
The command names(fRegressList) reveals a component betaestlist containing the estimated regression coefficient functions. Each of these is a func¬tional parameter object. We can plot the estimate of the regression function for the temperature profiles with the commands
betaestlist = fRegressListbetaestlisttempbetafd=betaestlist[[2]]fd plot(tempbetafd, xlab="Day", ylab="Beta for temperature")
Figure 9.1 shows the result. The intercept term can be obtained from coef( betaestlist[[1]]); its value in this case is 0.0095. We will defer commenting on these estimates until we consider the next more sophisticated strategy.
We need to assess the quality of this fit. First, let us extract the fitted values defined by this model and compute the residuals. We will also compute error sums of squares associated with the fit as well as for the fit using only a constant or intercept.
annualprechat1 = fRegressList$yhatfdobj annualprecres1 = annualprec - annualprechatl SSE1.1 = sum(annualprecres1"2)
SSE0 = sum((annualprec - mean(annualprec))"2)
0 100 200 300
Day
Fig. 9.1 Estimated p(t) for predicting log annual precipitation from average daily temperature using five Fourier basis functions.
We can now compute the squared multiple correlation and the usual F-ratio for comparing these two fits.
RSQ1 = (SSE0-SSE1.1)/SSE0
Fratiol = ((SSE0-SSE1)/5)/(SSE1/29)
The squared multiple correlation is 0.80, and the corresponding F-ratio with 5 and 29 degrees of freedom is 22.6, suggesting a fit to the data that is far better than we would expect by chance.
9.4.2 Coefficient p Estimate Using a Roughness Penalty
There are two ways to obtain a smooth fit. The simplest is to use a low-dimensional basis for P(t). However, we can get more direct control over what we mean by “smooth” by using a roughness penalty. The combination of a high-dimensional basis with a roughness penalty reduces the possibilities that either (a) important features are missed or (b) extraneous features are forced into the image by using a basis set that is too small for the application.
Suppose, for example, that we fit (9.2) by minimizing the penalized sum of squares
PENSSEa(an,p) = £加一a - ZXi(t)p(t)dt]2 + Z Z[Lp(t)]2dt. (9.4) This allows us to shrink variation in 0 as close as we wish to the solution of the dif-ferential equation L0 = 0. Suppose, for example, that we are working with periodic data with a known period. As noted with expression (5.11), the use of a harmonic acceleration operator,
L0 = (rn 2) D0 + D3 0,
places no penalty on a simple sine wave and increases the penalty on higher-order harmonics in a Fourier approximation approximately in proportion to the sixth power of the order of the harmonic. (In this expression,① is determined by the pe-riod, which is assumed to be known.) Thus, increasing the penalty 入 in (9.4) forces 0 to look more and more like 0 (t) = c 1 + c2 sin(①t) + c3 cos(①t).
More than one functional covariate can be incorporated into this model and scalar covariates may also be included. Let us suppose that in addition to yi we have measured p scalar covariates zi = (zi 1,...,zip) and q functional covariates Xi 1 (t),...,xiq(t). We can put these into a linear model as follows
q ,
a0 + 4a + 工J Xij(t)0j(t)dt + a,
where zi is the p - vector of scalar covariates. A separate smoothing penalty may be employed for each of the 0j (t), j = 1,..., q.
Using (9.5), we can define a least-squares estimate as follows. We define Z by:
—JX 11(t画(t)dt ••• XX1 q(t鸣(t)-
Z =. : .
. .
Z'nRXn 1(t)01(t)dt …RXnq(t陶(t)
Here 0k is the basis expansion used to represent 0k(t). We also define a penalty matrix
0
0 ZIR1 ••• 0
R(A)= . . . . (9.6)
. . . .
一 0…3
where Rk is the penalty matrix associated with the smoothing penalty for 0k and Zk is the corresponding smoothing parameter. With these objects, we can define
b = °Z0Z + R(Z))-1 Z0y
to hold the vector of estimated coefficients a along with the coefficients defining each estimated coefficient function 0k (t) estimated by penalized least squares. These are then extracted to form the appropriate functional data objects.
Now let us apply this approach to predicting the log annual precipitations. First, we set up a harmonic acceleration operator, as we did already in Chapter 5.
Lcoef = c(0,(2*pi/365)-2,0)
harmaccelLfd = vec2Lfd(Lcoef, c(0,365))
Now we replace our previous choice of basis for defining the 0 estimate by a func-tional parameter object that incorporates both this roughness penalty and a level of smoothing:
betabasis = create.fourier.basis(c(0, 365), 35) lambda = 10"12.5
betafdPar = fdPar(betabasis, harmaccelLfd, lambda) betalist[[2]] = betafdPar
These now allow us to invoke fRegress to return the estimated functional coeffi-cients and predicted values:
annPrecTemp = fRegress(annualprec, templist, betalist)
betaestlist2 = annPrecTempbetaestlistannualprechat2=annPrecTempyhatfdobj
The command print(fRegressListbetaestlist