Chapter 5 Estimating Coefficients From Real Data

book, fda, r

regression approach

This is basically using least square to estimate the coefficients of spline functions.

Then and

We can use simple R functions lsfit to estimate the $\Phi$ as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#  define the range
Rng  = c(1,18)
age     = growth$age
agefine = seq(1,18,len=501)
#  set up order 6 spline basis with 12 basis functions for
#  fitting the growth data so as to estimate acceleration
nbasis = 12;
norder =  6;
heightbasis12 = create.bspline.basis(ageRng, nbasis, norder)
#  fit the data by least squares
basismat   = eval.basis(age, heightbasis12)
heightmat  = growth$hgtf
heightcoef = lsfit(basismat, heightmat, intercept=FALSE)$coef

# heightcoef is a 12 * 54 matrix. Each column represents the coefficients for 12 basis functions for each boy. 

Or there is a function in the fda package: smooth.basis. This function takes three arguments, $t_j, y_j$ and $\Phi$. That is, the support of the responses, the responses and the bspline basis system. It returns a fd object and several other things.

1
2
3
4
5
6
7
heightList = smooth.basis(age, heightmat[,1:5], heightbasis12)
(heightfd   = heightList$fd)
(height.df  = heightList$df)
[1] 12
(height.gcv = heightList$gcv)
   girl01    girl02    girl03    girl04    girl05
0.2513923 0.7977237 0.3340652 0.3085981 0.3479272

roughness penalty

A measure of a function’s roughness is the integrated square second derivative or total curvature