Predict Loess Curve or Surface
Predictions from a
loess fit, optionally with standard errors.
# S3 method for loess predict(object, newdata = NULL, se = FALSE, na.action = na.pass, …)
- an object fitted by
- an optional data frame in which to look for variables with which to predict, or a matrix or vector containing exactly the variables needs for prediction. If missing, the original data points are used.
- should standard errors be computed?
- function determining what should be done with missing
values in data frame
newdata. The default is to predict
- arguments passed to or from other methods.
The standard errors calculation is slower than prediction. When the fit was made using
surface = "interpolate" (the
predict.loess will not extrapolate -- so points outside
an axis-aligned hypercube enclosing the original data will have
NA) predictions and standard errors.
se = FALSE, a vector giving the prediction for each row of
newdata (or the original data). If
se = TRUE, a list
newdatawas the result of a call to
expand.grid, the predictions (and s.e.'s if requested) will be an array of the appropriate dimensions. Predictions from infinite inputs will be
loessdoes not support extrapolation.
Variables are first looked for in
newdata and then searched for
in the usual way (which will include the environment of the formula
used in the fit). A warning will be given if the
variables found are not of the same length as those in
if it was supplied.
cars.lo <- loess(dist ~ speed, cars) predict(cars.lo, data.frame(speed = seq(5, 30, 1)), se = TRUE) # to get extrapolation cars.lo2 <- loess(dist ~ speed, cars, control = loess.control(surface = "direct")) predict(cars.lo2, data.frame(speed = seq(5, 30, 1)), se = TRUE)