Train and test a MARS model with R
library(earth)
######### TRAIN
mars.model = earth(y = train.dataset, x = train.covariates)
# Disccover selected covariates
selected.covariates = mars.model$namesx[(colSums(mars.model$cuts) != 0)]
######### TEST
predict = as.numeric(predict(mars.model, newdata = test.covariates))