if (require(mda)) {
a <- mars(trees[,-3], trees[,3])
a <- mars.to.earth(a)
summary(a, digits = 2) # the standard earth functions can now be used
# yields (note the reconstructed call):
# Call: earth(x=trees[, -3], y=trees[, 3])
#
# y
# (Intercept) 19.76
# h(Girth-12) 5.40
# h(12-Girth) -2.56
# h(Height-76) 0.72
#
# Selected 4 of 5 terms, and 2 of 2 predictors
# Importance: Girth, Height
# Number of terms at each degree of interaction: 1 3 (additive model)
# GCV 13 RSS 251 GRSq 0.95 RSq 0.97
}
Run the code above in your browser using DataLab