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)
#
# Volume
# (Intercept) 23.208
# h(Girth-12.9) 5.746
# h(12.9-Girth) -2.866
# h(Height-76) 0.718
#
# Selected 4 of 5 terms, and 2 of 2 predictors
# Estimated importance: Girth Height
# Number of terms at each degree of interaction: 1 3 (additive model)
# GCV 11.48697 RSS 213.4354 GRSq 0.958859 RSq 0.9736697
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
# -5.2900 -1.9782 0.0712 1.9209 4.1267
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 23.208 0.997 23.28 < 2e-16
# bx[, -1]h(Girth-12.9) 5.746 0.297 19.35 < 2e-16
# bx[, -1]h(12.9-Girth) -2.866 0.444 -6.45 6.5e-07
# bx[, -1]h(Height-76) 0.718 0.175 4.10 0.00034
#
# Residual standard error: 2.81 on 27 degrees of freedom
# Multiple R-squared: 0.974, Adjusted R-squared: 0.971
# F-statistic: 333 on 3 and 27 DF, p-value: <2e-16
Run the code above in your browser using DataLab