Learn R Programming

fda.usc (version 1.2.3)

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,se.fit=FALSE, 
        scale = NULL,df=df, interval = "none", level = 0.95,
        weights = 1, pred.var = res.var/weights,\dots)

Arguments

object
fregre.fd object.
new.fdataobj
New functional explanatory data of fdata class.
se.fit
=TRUE (not default) standard error estimates are returned for each prediction.
scale
Scale parameter for std.err. calculation.
df
Degrees of freedom for scale.
interval
Type of interval calculation.
level
Tolerance/confidence level.
pred.var
the variance(s) for future observations to be assumed for prediction intervals. See link{predict.lm} for more details.
weights
variance weights for prediction. This can be a numeric vector or a one-sided model formula. In the latter case, it is interpreted as an expression evaluated in newdata
...
Further arguments passed to or from other methods.

Value

  • If se.fit = FALSE, a vector of predictions of scalar response is returned or a matrix of predictions and bounds with column names fit, lwr, and upr if interval is set. If se.fit =TRUE a list with the following components is returned:
  • fitA vector of predictions or a matrix of predictions and bounds as above
  • se.fitAssociated standard error estimates of predictions
  • residual.scaleResidual standard deviations
  • dfDegrees of freedom for residual

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)
pred.pc=predict.fregre.fd(res.pc,newx)
# Functional PLS regression
res.pls=fregre.pls(x,y,1:6)
pred.pls=predict.fregre.fd(res.pls,newx)
# Functional nonparametric regression
res.np=fregre.np(x,y,Ker=AKer.tri,metric=semimetric.deriv)
pred.np=predict.fregre.fd(res.np,newx)
# Functional regression with basis representation
res.basis=fregre.basis.cv(x,y)
pred.basis=predict.fregre.fd(res.basis,newx)
 
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