# Example 1
data(trees)
earth.mod <- earth(Volume ~ ., data = trees) # standard earth model
summary(earth.mod, decomp = "none") # "none" to print terms in same order as lm.mod below
bx <- model.matrix(earth.mod) # earth model's basis mat (equivalent to bx <- earth.mod$bx)
lm.mod <- lm(trees$Volume ~ bx[,-1]) # -1 to drop intercept
summary(lm.mod) # yields same coeffs as above summary
# displayed t values are not meaningful
# Example 2
earth.mod <- earth(Volume~., data=trees) # standard earth model
summary(earth.mod, decomp = "none") # "none" to print terms in same order as lm.mod below
bx <- model.matrix(earth.mod) # earth model's basis mat (equivalent to bx <- earth.mod$bx)
bx <- bx[, -1] # drop intercept column
bx <- as.data.frame(bx) # lm requires a data frame
bx$Volume <- trees$Volume # add Volume to data
lm.mod <- lm(Volume~., data=bx) # standard linear regression on earth's basis mat
summary(lm.mod) # yields same coeffs as above summary
# displayed t values are not meaningful
Run the code above in your browser using DataLab