Agnese Giacomello
Agnese Giacomello

Reputation: 43

Caret: family specification in glmboost doesn't work

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.

Upvotes: 0

Views: 262

Answers (1)

MrFlick
MrFlick

Reputation: 206556

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.

Upvotes: 1

Related Questions