data(tecator)
x=tecator$absorp.fdata
newx=tecator$absorp.fdata
y=tecator$y$Fat
dataf=as.data.frame(tecator$y)
f=Fat~Water+x
ldata=list("df"=dataf,"x"=x)
res.plm=fregre.plm(f,ldata)
summary(res.plm)
# with 2nd derivative of functional data
x.fd=fdata.deriv(x,nderiv=2)
f2=Fat~Water+x.fd
ldata2=list("df"=dataf,"x.fd"=x.fd)
res.plm2=fregre.plm(f2,ldata2)#,Ker=AKer.tri)
summary(res.plm)
par(mfrow=c(2,1))
plot(y,res.plm$fitted.values)
points(y,res.plm2$fitted.values,col=2)
plot(res.plm$residuals)
points(res.plm2$residuals,col=2)
# fregre.plm as fregre.np.cv
f=Fat~+x
res.np=fregre.plm(f,ldata)
res.np2=fregre.np.cv(x,y)
res.np
res.np2
# fregre.plm as lm
f=Fat~+Water
res.lm=fregre.plm(f,ldata)
res.lm2=lm(f,dataf)
res.lm
res.lm2Run the code above in your browser using DataLab