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)
Run the code above in your browser using DataLab