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

View source: R/predict.fregre.fd.r

predict.fregre.fdR Documentation

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.

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.

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,
  ...
)

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.

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

pred.var

the variance(s) for future observations to be assumed for prediction intervals. See link{predict.lm} for more details.

...

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:

  • fit A vector of predictions or a matrix of predictions and bounds as above

  • se.fit Associated standard error estimates of predictions

  • residual.scale Residual standard deviations

  • df Degrees of freedom for residual

Author(s)

Manuel Febrero-Bande, Manuel Oviedo de la Fuente manuel.oviedo@udc.es

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. https://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

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

## End(Not run)


fda.usc documentation built on Oct. 17, 2022, 9:06 a.m.