Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

predict.bagEarth

Predicted values based on bagged Earth and FDA models


Description

Predicted values based on bagged Earth and FDA models

Usage

## S3 method for class 'bagEarth'
predict(object, newdata = NULL, type = NULL, ...)

## S3 method for class 'bagFDA'
predict(object, newdata = NULL, type = "class", ...)

Arguments

object

Object of class inheriting from bagEarth

newdata

An optional data frame or matrix in which to look for variables with which to predict. If omitted, the fitted values are used (see note below).

type

The type of prediction. For bagged earth regression model, type = "response" will produce a numeric vector of the usual model predictions. earth also allows the user to fit generalized linear models. In this case, type = "response" produces the inverse link results as a vector. In the case of a binomial generalized linear model, type = "response" produces a vector of probabilities, type = "class" generates a factor vector and type = "prob" produces a two-column matrix with probabilities for both classes (averaged across the individual models). Similarly, for bagged fda models, type = "class" generates a factor vector and type = "probs" outputs a matrix of class probabilities.

...

not used

Value

A vector of predictions (for regression or type = "class") or a data frame of class probabilities. By default, when the model predicts a number, a vector of numeric predictions is returned. When a classification model is used, the default prediction is a factor vector of classes.

Note

If the predictions for the original training set are needed, there are two ways to calculate them. First, the original data set can be predicted by each bagged earth model. Secondly, the predictions from each bootstrap sample could be used (but are more likely to overfit). If the original call to bagEarth or bagFDA had keepX = TRUE, the first method is used, otherwise the values are calculated via the second method.

Author(s)

Max Kuhn

See Also

Examples

## Not run: 
data(trees)
## out of bag predictions vs just re-predicting the training set
set.seed(655)
fit1 <- bagEarth(Volume ~ ., data = trees, keepX = TRUE)
set.seed(655)
fit2 <- bagEarth(Volume ~ ., data = trees, keepX = FALSE)
hist(predict(fit1) - predict(fit2))

## End(Not run)

caret

Classification and Regression Training

v6.0-86
GPL (>= 2)
Authors
Max Kuhn [aut, cre], Jed Wing [ctb], Steve Weston [ctb], Andre Williams [ctb], Chris Keefer [ctb], Allan Engelhardt [ctb], Tony Cooper [ctb], Zachary Mayer [ctb], Brenton Kenkel [ctb], R Core Team [ctb], Michael Benesty [ctb], Reynald Lescarbeau [ctb], Andrew Ziem [ctb], Luca Scrucca [ctb], Yuan Tang [ctb], Can Candan [ctb], Tyler Hunt [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.