fregre.basis.cv() uses validation criterion defined by argument type.CV to estimate the number of basis elements and/or the penalized parameter (lambda) that best predicts the response.fregre.basis.cv(fdataobj,y,basis.x=NULL,basis.b=NULL,
type.basis=NULL,lambda=0,Lfdobj=vec2Lfd(c(0,0),rtt),
type.CV=GCV.S,par.CV=list(trim=0),...)fdata class object.n.fdataobj.basis.x or basis.b are a vector of number of basis considered.lambda=0.GCV.S method.type.CV: trim, the alpha of the trimming and draw.fdy minus fitted values.fdata.lambda value that minimizes CV or GCV method.fdata.beta parameter estimation.lm object.basis = NULL creates bspline basis.
If the functional covariate fdataobj is in a format raw data, such as matrix or data.frame, creates an object of class fdata with default attributes, see fdata.
If basis.x$type=``fourier'' and basis.b$type=``fourier'', the basis are orthonormal and the function decreases the number of fourier basis elements on the $min(k_{n1},k_{n2})$, where $k_{n1}$ and $k_{n2}$ are the number of basis element of basis.x and basis.b respectively.fregre.basis, summary.fregre.fd and predict.fregre.fd .
Alternative method: fregre.pc.cv and fregre.np.cv.data(tecator)
x<-tecator$absorp.fdata[1:129]
y=tecator$y$Fat[1:129]
tt=x[["argvals"]]
b=seq(7,47,by=8)
l=2^(-4:10)
res=fregre.basis.cv(x,y,basis.b=b,type.basis="fourier",
lambda=l,type.CV=GCV.S,par.CV=list(trim=0.15))
summary(res)Run the code above in your browser using DataLab