Search code examples
rr-caretglmspline

how to pass glm control argument for earth using caret (maxit)


when fitting earth for a glm model, one can pass arguments to the glm call. For example:

mars_fit <- earth(formula = response ~ x1 + x2, data = sim_dat,
                      glm = list(family=binomial, control = list(maxit = 50)))

Using caret looks like

fit_control <- trainControl(method = "cv", number = 10)
mars_grid <- expand.grid(degree=1:2, nprune=2:10)
mars_fit <- train(factor(response)~x1+x2, method='earth', trControl = fit_control, 
                  data=sim_dat, tuneGrid=mars_grid, 
                  glm = list(control = list(maxit = 50)))

but the glm list is not passed. Any advice?

Edit 1: Reading https://github.com/topepo/caret/issues/554 caret's author says it is either caught in the ... or it should be passed in the tuning grid. when passed through the tuning grid, since glm is a list, train complains that degree and nprune do not belong to the method, which is not true. Edit 2: Opened https://github.com/topepo/caret/issues/1018


Solution

  • issue is solved in this commit: https://github.com/topepo/caret/commit/2ce2cf4c5889791b7dbca5d8896fcc6dc0d0bcfc