data(trees)
a <- earth(Volume ~ ., data = trees)
summary(a, decomp = "none") # "none" to print terms in same seq as a.lm below
# yields:
# Call:
# earth(formula = Volume ~ ., data = trees)
#
# Expression:
# 26.64062
# + 6.049141 * pmax(0, Girth - 13.7)
# - 3.202820 * pmax(0, 13.7 - Girth)
# + 0.6079078 * pmax(0, Height - 75)
#
# Number of cases: 31
# Selected 4 of 5 terms, and 2 of 2 predictors
# Number of terms at each degree of interaction: 1 3 (additive model)
# GCV: 10.56081 RSS: 196.2266 GRSq: 0.962176 RSq: 0.9757927
bx <- model.matrix(a) # equivalent to bx <- a$bx
a.lm <- lm(trees$Volume ~ bx[,-1]) # -1 to drop intercept
summary(a.lm) # yields same coeffs as above summary
# displayed p values are not meaningful
# yields:
# Call:
# lm(formula = trees$Volume ~ bx[, -1])
#
# Residuals:
# Min 1Q Median 3Q Max
# -4.691469 -1.987719 0.008402 1.421682 4.820064
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 26.6406 1.0019 26.590 < 2e-16
# bx[, -1]h(Girth-13.7) 6.0491 0.3344 18.087 < 2e-16
# bx[, -1]h(13.7-Girth) -3.2028 0.3502 -9.146 9.3e-10
# bx[, -1]h(Height-75) 0.6079 0.1531 3.972 0.000477
#
# Residual standard error: 2.696 on 27 degrees of freedom
# Multiple R-Squared: 0.9758, Adjusted R-squared: 0.9731
# F-statistic: 362.8 on 3 and 27 DF, p-value: < 2.2e-16
Run the code above in your browser using DataLab