0

I am working on a MARS model using earth package in R. I want to force all the variables in the model. I have 14 predictors but in the result, I am getting only 13 predictors. Below is my code.

mdl <- earth(x,y,nprune=10000, nk=1000, degree=1, thresh=1e-7,
        linpreds=c(1:14), penalty = -1,  ponly=T, trace = 0)

Here are my questions

  1. Is it possible for me to force variables instead of some variable selection. If yes, how?\
  2. Once I start exploring hinges in the data, is it possible for me to manually fix the knots and then ge tthe estimates on the basis of them.
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
maverick
  • 1
  • 3

1 Answers1

3

You cannot force predictors into the earth/MARS model. Fundamental to the MARS algorithm is automatic selection of predictors.

But it is possible to increase the likelihood of all predictors going into the model by subverting the normal algorithm by setting thresh=0 and penalty=-1. See the earth help page, and search for "thresh" and "penalty" in the earth vignette for details and examples.

However, to quote that vignette: "It’s usually best not to subvert the standard MARS algorithm by toying with tuning parameters such as thresh, penalty, and endspan. Remember that we aren’t seeking a model that best fits the training data, but rather a model that best fits the underlying distribution."

You can't manually fix the knots. Once again, automatic selection of knots if inherent in the MARS algorithm. However, the minspan and endspan arguments give you some flexibility in the automatic placement of knots, for example minspan=-3 will allow up to 3 equally spaced knots per predictor.

Stephen Milborrow
  • 976
  • 10
  • 14