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)
#
# coefficients
# (Intercept) 27.246
# h(Girth-14) 6.177
# h(14-Girth) -3.266
# h(Height-72) 0.491
#
# Selected 4 of 6 terms, and 2 of 2 predictors
# Importance: Girth, Height
# Number of terms at each degree of interaction: 1 3 (additive model)
# GCV 10.6 RSS 197 GRSq 0.962 RSq 0.976
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 t values are not meaningful
# yields:
# Call:
# lm(formula = trees$Volume ~ bx[, -1])
#
# Residuals:
# Min 1Q Median 3Q Max
# -4.882 -1.770 0.281 1.646 4.983
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 27.246 1.123 24.26 < 2e-16
# bx[, -1]h(Girth-14) 6.177 0.354 17.44 3.2e-16
# bx[, -1]h(14-Girth) -3.266 0.335 -9.76 2.4e-10
# bx[, -1]h(Height-72) 0.491 0.123 3.99 0.00045
#
# Residual standard error: 2.7 on 27 degrees of freedom
# Multiple R-squared: 0.976, Adjusted R-squared: 0.973
# F-statistic: 361 on 3 and 27 DF, p-value: <2e-16
Run the code above in your browser using DataLab