0

I'm trying to run a boosted robust regression on Caret (with the Huber family), however I get an error when training the model:

library(caret)

X <- rnorm(300, 0, 100)
Y <- rnorm(300, 0, 100000)
data <- cbind(X,Y)

model <- train(Y~X, method="glmboost", data=data, family=Huber())

I get the error 'could not find function Huber()', however this is explicitly included in the mboost package (the one on which glmboost is based).

Any help would be really appreciated.

  • @MrFlick here https://rdrr.io/cran/mboost/man/Family.html you can find all family specifications available in the mboost package. In the documentation as well it is explained that Huber is one of the two robust families available. I added a reproducible example, which as I wrote before returns 'could not find function Huber()'. I think the only solution would be to write my own model in Caret, right? Thank you a lot for your help! – Agnese Giacomello Apr 09 '19 at 18:57
  • @MrFlick it does work ! I thought mboost was already internally loaded by caret once you require the glmboost model. Infinite thanks, if you post it as an answer I can upvote it. – Agnese Giacomello Apr 10 '19 at 07:18

1 Answers1

1

If you Just run library(caret) with method="glmboost" it will load the mboost package, but it will not attach the mboost package to your search path. Packages are discouraged from automatically attaching other packages since they may import functions that could conflict with other functions you have loaded. Thus most packages load dependencies privately. If you fully qualify the function name with the package name, then you can use it in your model

model <- train(Y~X, method="glmboost", data=data, family=mboost::Huber())

Or you could just also run library(mboost) to attach the package to your search path so you don't have to include the package name prefix.

MrFlick
  • 195,160
  • 17
  • 277
  • 295