Description Usage Arguments Value Note See Also Examples

View source: R/predict.earth.R

Predict with an `earth`

model.

1 2 3 4 5 |

`object` |
An |

`newdata` |
Make predictions using |

`type` |
Type of prediction.
One of |

`interval` |
Return prediction or confidence levels.
Default is |

`level` |
Confidence level for the |

`thresh` |
Threshold, a value between 0 and 1 when predicting a probability.
Only applies when |

`trace` |
Default |

`...` |
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.

**Predicting with standard earth models**

Use the default `type="link"`

, or possibly `type="class"`

.

Actually, the `"link"`

, `"response"`

, and `"earth"`

choices all return the same value unless the `glm`

argument
was used in the original call to `earth`

.

**Predicting with earth-GLM models**

This section applies to earth models with a GLM component, i.e.,
when the `glm`

argument was used
in the original call to `earth`

.

The `"link"`

and `"response"`

options:
see `predict.glm`

for a description of these.
In brief: for logistic models
use `type="response"`

to get probabilities,
and `type="link"`

to get log-odds.

Use option `"earth"`

to get the linear fit (this gives the prediction you would get
if your original call to earth had no `glm`

argument).

**Predicting with "class"**

Use option `"class"`

to get the predicted class.
With option `"class"`

, this function first makes predictions with
`type="response"`

and then assigns the predicted values to classes as follows:

(i) When the response is a *logical*, predict `TRUE`

if
the predicted probability is greater than `thresh`

(default `0.5`

).

(ii) When the response is a *numeric*, predict `TRUE`

if
the predicted value is greater than `thresh`

.
Actually, this is identical to the above case,
although `thresh`

here may legitimately be a value
outside the 0...1 range.

(iii) When the response is a *two level factor*,
predict the second level if its probability is more than `thresh`

.
In other words, with the default `thresh=0.5`

predict the most probable level.

(iv) When the response is a *three or more level factor*,
predict the most probable level (and `thresh`

is ignored).

**Predicting with "terms"**

The `"terms"`

option returns a `"link"`

response suitable for `termplot`

.
Only the additive terms and the first response (for multi-response models) are returned.
Also, `"terms"`

always returns the earth terms, and ignores the GLM component
of the model, if any.

1 2 3 4 5 |

```
Loading required package: Formula
Loading required package: plotmo
Loading required package: plotrix
Loading required package: TeachingDemos
Volume
[1,] 8.883097
[2,] 9.909039
[3,] 10.593000
[4,] 16.406671
[5,] 20.578818
[6,] 22.083528
[7,] 18.116574
[8,] 18.116574
[9,] 21.365376
[10,] 18.800535
[11,] 21.467973
[12,] 20.065861
[13,] 20.065861
[14,] 20.510438
[15,] 21.536380
[16,] 24.614206
[17,] 30.427849
[18,] 32.377136
[19,] 27.350050
[20,] 27.692031
[21,] 30.120085
[22,] 31.966775
[23,] 30.928808
[24,] 40.273079
[25,] 43.304662
[26,] 51.859634
[27,] 53.686902
[28,] 55.015978
[29,] 55.638930
[30,] 55.638930
[31,] 75.905218
Volume
[1,] 17.60359
Volume
[1,] 17.60359
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.