Description Usage Arguments Note See Also Examples

A *variance model* estimates the variance of predicted values.
It can be used to estimate prediction intervals.
See the `interval`

argument of `predict.earth`

.

A variance model is built by `earth`

if `earth`

's
`varmod.method`

argument is specified.
Results are stored in the `$varmod`

field of the `earth`

model.
See the vignette “Variance models in earth” for details.

You probably won't need to directly call
`print.varmod`

or `summary.varmod`

.
They get called internally by `summary.earth`

.

1 2 3 4 5 6 7 8 |

`object` |
A |

`level` |
Same as |

`style` |
Determines how the coefficients of the |

`digits` |
Number of digits to print. Default is |

`newdata` |
Default |

`...` |
Dots are passed on. |

A `"varmod"`

object has the following fields:

`call`

The call used internally in the parent model to build the`varmod`

object.`parent`

The parent`earth`

model.`method`

Copy of the`varmod.method`

argument to the parent model.`package`

NULL, unless`method="gam"`

, in which case either`"gam"`

or`"mgcv"`

.`exponent`

Copy of the`varmod.exponent`

argument to the parent model.`lambda`

Currently always 1, meaning use absolute residuals.`rmethod`

Currently always "hc2", meaning correct the residuals with`1/(1-h_ii)`

.`converged`

Did the residual submodel IRLS converge?`iters`

Number of residual model IRLS iterations (1 to 50).`residmod`

The residual submodel. So for example, if`varmod.method="lm"`

, this will be an`lm`

object.`min.sd`

The predicted residual standard deviation is clamped so it will always be at least this value. This prevents prediction of negative or absurdly small variances. See`earth`

's`varmod.clamp`

argument. Clamping takes place in`predict.varmod`

, which is called by`predict.earth`

when estimating prediction intervals.`model.var`

An n x 1 matrix. The`model.var`

for an observation is the estimated model variance for that observation over all datasets, and is estimated with repeated cross validation. It is the variance of the mean out-of-fold prediction for that observation over`ncross`

repetitions.`abs.resids`

An n x 1 matrix. The absolute residuals used to build the residual model.`parent.x`

An n x p matrix. Parent earth model`x`

.`parent.y`

An n x 1 matrix. Parent earth model`y`

.`iter.rsq`

Weighted R-Squared of residual submodel`residmod`

, after IRLS iteration.`iter.stderr`

Standard errors of the coefficients of the residual submodel`residmod`

, after IRLS iteration.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
data(ozone1)
set.seed(1) # optional, for cross validation reproducibility
# note: should really use ncross=30 below but for a quick demo we don't
earth.mod <- earth(O3~temp, data=ozone1, nfold=10, ncross=3, varmod.method="lm")
print(summary(earth.mod)) # note additional info on the variance model
old.mfrow <- par(mfrow=c(2,2), mar=c(3, 3, 3, 1), mgp=c(1.5, 0.5, 0))
plotmo(earth.mod, do.par=FALSE, response.col=1, level=.90, main="earth model: O3~temp")
plot(earth.mod, which=3, level=.90) # residual plot: note 90% pred and darker conf intervals
par(par=old.mfrow)
``` |

```
Loading required package: plotmo
Loading required package: plotrix
Loading required package: TeachingDemos
Call: earth(formula=O3~temp, data=ozone1, nfold=10, ncross=3,
varmod.method="lm")
coefficients
(Intercept) 7.5768304
h(58-temp) -0.1572930
h(temp-58) 0.6090229
Selected 3 of 4 terms, and 1 of 1 predictors
Termination condition: RSq changed by less than 0.001 at 4 terms
Importance: temp
Number of terms at each degree of interaction: 1 2 (additive model)
GCV 22.43818 RSS 7181.917 GRSq 0.6514492 RSq 0.6598731 CVRSq 0.6168999
Note: the cross-validation sd's below are standard deviations across folds
Cross validation: nterms 3.37 sd 0.89 nvars 1.00 sd 0.00
CVRSq sd MaxErr sd
0.617 0.107 17.2 11.1
varmod: method "lm" min.sd 0.465 iter.rsq 0.141
stddev of predictions:
coefficients iter.stderr iter.stderr%
(Intercept) 1.5386899 0.340864 22
O3 0.2645253 0.0361091 14
mean smallest largest ratio
95% prediction interval 18.24207 8.505812 35.99091 4.231331
68% 80% 90% 95%
response values in prediction interval 70 82 92 97
```

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.