Learn R Programming

fda.usc (version 1.0.0)

predict.fregre.fd: Predict method for functional linear model (fregre.fd class)

Description

Computes predictions for regression between functional explanatory variables and scalar response using: basis representation, Principal Components Analysis, Partial least squares or nonparametric kernel estimation.

Usage

## S3 method for class 'fregre.fd':
predict(object,new.fdataobj=NULL,\dots)

Arguments

object
fregre.fd object.
new.fdataobj
New functional explanatory data of fdata class.
...
Further arguments passed to or from other methods.

Value

  • Return:
  • fitted.valuesPredited scalar response.

Details

Predicts from a fitted fregre.basis object,see fregre.basis or fregre.basis.cv Predicts from a fitted fregre.pc object,see fregre.pc or fregre.pc.cv Predicts from a fitted fregre.pls object,see fregre.pls or fregre.pls.cv Predicts from a fitted fregre.np object, see fregre.np or fregre.np.cv.

References

Cai TT, Hall P. 2006. Prediction in functional linear regression. Annals of Statistics 34: 2159{-}2179. Cardot H, Ferraty F, Sarda P. 1999. Functional linear model. Statistics and Probability Letters 45: 11{-}22. Ferraty, F. and Vieu, P. (2006). Nonparametric functional data analysis. Springer Series in Statistics, New York. Hall P, Hosseini{-}Nasab M. 2006. On properties of functional principal components analysis. Journal of the Royal Statistical Society B 68: 109{-}126. Hardle, W. Applied Nonparametric Regression. Cambridge University Press, 1994. Ramsay, James O., and Silverman, Bernard W. (2006), Functional Data Analysis, 2nd ed., Springer, New York. Febrero-Bande, M., Oviedo de la Fuente, M. (2012). Statistical Computing in Functional Data Analysis: The R Package fda.usc. Journal of Statistical Software, 51(4), 1-28. http://www.jstatsoft.org/v51/i04/

See Also

See Also as: fregre.basis, fregre.basis.cv, fregre.np, fregre.np.cv, fregre.pc, fregre.pc.cv, fregre.pls, fregre.pls.cv and summary.fregre.fd.

Examples

Run this code
data(tecator)
absorp=tecator$absorp.fdata
ind=1:129
x=absorp[ind,]
y=tecator$y$Fat[ind]

newx=absorp[-ind,]
newy=matrix(tecator$y$Fat[-ind],ncol=1)

# Functional PC regression
res.pc=fregre.pc(x,y,1:6)
summary(res.pc)
pred.pc=predict.fregre.fd(res.pc,newx)

## Functional PLS regression
# res.pls=fregre.pls(x,y,1:6)
# summary(res.pls)
# pred.pls=predict.fregre.fd(res.pls,newx)

## Functional nonparametric regression
## Functional nonparametric regression with other semimetric.
# res.np=fregre.np(x,y,Ker=AKer.tri,metric=semimetric.deriv)
# summary(res.np)
# pred.np=predict.fregre.fd(res.np,newx)


## Functional regression with basis representation

# res.basis=fregre.basis.cv(x,y)
# summary(res.basis)
# pred.basis=predict.fregre.fd(res.basis,newx)

# x.d=fdata.deriv(x,nbasis=19,nderiv=1)
# res.basis2=fregre.basis.cv(x.d,y)
# summary(res.basis2)
# newx.d=fdata.deriv(newx,nbasis=19,nderiv=1)
# pred.basis2=predict.fregre.fd(res.basis2,newx.d)

# dev.new()
# plot(pred.pc-newy)
# points(pred.pls-newy,col=2,pch=2)
# points(pred.np-newy,col=3,pch=3)
# points(pred.basis-newy,col=4,pch=4)
# sum((pred.pc-newy)^2,na.rm=TRUE)/sum((newy-mean(newy))^2,na.rm=TRUE)
# sum((pred.pls-newy)^2,na.rm=TRUE)/sum((newy-mean(newy))^2,na.rm=TRUE)
# sum((pred.np-newy)^2,na.rm=TRUE)/sum((newy-mean(newy))^2,na.rm=TRUE)
# sum((pred.basis-newy)^2,na.rm=TRUE)/sum((newy-mean(newy))^2,na.rm=TRUE)

Run the code above in your browser using DataLab