fda (version 6.1.8)

predict.fRegress: Predict method for Functional Regression

Description

Model predictions for object of class fRegress.

Usage

# S3 method for fRegress
predict(object, newdata=NULL, se.fit = FALSE,
     interval = c("none", "confidence", "prediction"),
     level = 0.95, ...)

Value

The predictions produced by predict.fRegress are either a vector or a functional parameter (class fdPar) object, matching the class of object$y.

If interval is not "none", the predictions will be multivariate for object$y and the requested lwr and

upr bounds. If object$y is a scalar, these predictions are returned as a matrix; otherwise, they are a multivariate functional parameter object (class fdPar).

If se.fit is TRUE, predict.fRegress returns a list with the following components:

fit

vector or matrix or univariate or multivariate functional parameter object depending on the value of interval and the class of object$y.

se.fit

standard error of predicted means

Arguments

object

Object of class inheriting from fRegress

newdata

Either NULL or a list matching object$xfdlist.

If(is.null(newdata)) predictions <- object$yhatfdobj

If newdata is a list, predictions = the sum of either

newdata[i] * betaestfdlist[i] if object$yfdobj has class fd

or

inprod(newdata[i], betaestfdlist[i]) if class(object$yfdobj) = numeric.

se.fit

a switch indicating if standard errors of predictions are required

NOTE: se.fit = TRUE is NOT IMPLEMENTED YET.

interval

type of prediction (response or model term)

NOTE: Only "intervale = 'none'" has been implemented so far.

level

Tolerance/confidence level

...

additional arguments for other methods

Author

Spencer Graves

Details

1. Without newdata, fit <- object$yhatfdobj.

2. With newdata, if(class(object$y) == 'numeric'), fit <- sum over i of inprod(betaestlist[i], newdata[i]). Otherwise, fit <- sum over i of betaestlist[i] * newdata[i].

3. If(se.fit | (interval != 'none')) compute se.fit, then return whatever is desired.

References

Ramsay, James O., Hooker, Giles, and Graves, Spencer (2009), Functional data analysis with R and Matlab, Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2005), Functional Data Analysis, 2nd ed., Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2002), Applied Functional Data Analysis, Springer, New York.

See Also

fRegress predict

Examples

Run this code
##
## vector response with functional explanatory variable
##
if (FALSE) {
annualprec <- log10(apply(CanadianWeather$dailyAv[,,
                   "Precipitation.mm"], 2,sum))
smallbasis  <- create.fourier.basis(c(0, 365), 25)
tempfd <- smooth.basis(day.5,
   CanadianWeather$dailyAv[,,"Temperature.C"], smallbasis)$fd
precip.Temp.f <- fRegress(annualprec ~ tempfd)
precip.Temp.p <- predict(precip.Temp.f)
# plot response vs. fitted 
oldpar <- par(no.readonly=TRUE)
plot(annualprec, precip.Temp.p)
par(oldpar)
}

Run the code above in your browser using DataLab