earth (version 5.3.0) Predict with an earth model


Predict with an earth model.


# S3 method for earth
predict(object = stop("no 'object' argument"), newdata = NULL,
        type = c("link", "response", "earth", "class", "terms"),
        interval = "none", level = .95,
        thresh = .5, trace = FALSE, …)



An earth object. This is the only required argument.


Make predictions using newdata, which can be a data frame, a matrix, or a vector with length equal to a multiple of the number of columns of the original input matrix x. Default is NULL, meaning return values predicted from the training set. NAs are allowed in newdata (and the predicted value will be NA unless the NAs are in variables that are unused in the earth model).


Type of prediction. One of "link" (default), "response", "earth", "class", or "terms". See the Note below.


Return prediction or confidence levels. Default is "none". Use interval="pint" to get prediction intervals on new data.

Requires that the earth model was built with varmod.method.

This argument gets passed on as the type argument to predict.varmod. See its help page for details.


Confidence level for the interval argument. Default is 0.95, meaning construct 95% confidence bands (estimate the 2.5% and 97.5% levels).


Threshold, a value between 0 and 1 when predicting a probability. Only applies when type="class". Default is 0.5. See the Note below.


Default FALSE. Set to TRUE to see which data, subset, etc. is using.

Unused, but provided for generic/method consistency.


The predicted values (a matrix for multiple response models).

If type="terms", a matrix with each column showing the contribution of a predictor.

If interval="pint" or "cint", a matrix with three columns: fit: the predicted values lwr: the lower confidence or prediction limit upr: the upper confidence or prediction limit

If interval="se", the standard errors.

See Also

earth, predict


earth.mod <- earth(Volume ~ ., data = trees)
predict(earth.mod) # same as earth.mod$fitted.values
predict(earth.mod, data.frame(Girth=10, Height=80)) # yields 17.6
predict(earth.mod, c(10,80))                        # equivalent
# }