Learn R Programming

earth (version 2.5-1)

predict.earth: Predict with an "earth" model

Description

Predict with an earth model.

Usage

## S3 method for class 'earth':
predict(object = stop("no 'object' arg"), newdata = NULL,
        type = c("link", "response", "earth", "class", "terms"),
        thresh = .5, trace = FALSE, ...)

Arguments

object
An earth object. This is the only required argument.
newdata
Make predictions using newdata, which can be a data frame, a matrix, or a vector with length equal to a multiple of the column length of the original input matrix x. Note that this is more flexible than the predict me
type
Type of prediction. One of "link" (default), "response", "earth", "class", or "terms". See the Note below.
thresh
Threshold, a value between 0 and 1 when predicting a probability. Only applies when type="class". Default is .5. See the Note below.
trace
Default FALSE. Set to TRUE to see which data, subset, etc. predict.earth is using.
...
Unused, but provided for generic/method consistency.

Value

  • The predicted values (a matrix for multiple response models). Except if type="terms", then a matrix with each column showing the contribution of a predictor.

See Also

earth, predict

Examples

Run this code
data(trees)
a <- earth(Volume ~ ., data = trees)
predict(a)           # same as a$fitted.values
predict(a, c(10,80)) # yields 18.11

Run the code above in your browser using DataLab