predict.earth {earth}R Documentation

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", "terms"),
                        trace = FALSE, ...)

Arguments

object An earth object. This is the only required argument.
newdata Make predictions using newdata, which can be a dataframe, a matrix, or a vector with length equal to a multiple of the row length of the original input matrix x. Default is NULL, meaning return object's fitted values.
type Type of prediction. One of "link" (default), "response", "earth", or "term".

The "link", "response", and "earth" choices all return the same value unless the earth model has a GLM component (i.e. unless the glm argument was used in the original call to earth). See predict.glm for a description of the "link" and "response" options. (In brief: for logistic models use type="response" to return probabilities.)

"terms" returns an "earth" response suitable for termplot. Only the additive terms and the first response (for multi-response models) are returned. Also, "terms" always returns the earth (not GLM) terms.

trace Default FALSE. Set to TRUE to see which data, subset, etc. predict.earth is using.
... Unused, but provided for generic/method consistency.

Value

If type="terms", a matrix with each column showing the contribution of a predictor. Else the predicted values (a matrix for multiple response models).

See Also

earth, predict

Examples

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

[Package earth version 2.1-2 Index]