2

Let's take data :

y <- sample(0:1, 125, T)
x <- data.frame(rnorm(125), rexp(125))

I want to perform cross validation on data above, without intercept. To exclude intercept in linear models in caret we just need to use : tuneGrid = expand.grid(intercept = FALSE). However when applying this to binary models :

library(caret)
train(as.factor(y) ~ .,
           data = cbind(y,x),
           method = "glm",
           family = binomial(link = 'logit'),
           tuneGrid = expand.grid(intercept = FALSE),
           trControl = trainControl(
             method = "cv",
             number = 5
           )
)

I get error :

Error: The tuning parameter grid should have columns parameter

My question is : Do we have any possibility to omit intercept in caret binary models ?

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
John
  • 1,849
  • 2
  • 13
  • 23
  • Does this answer your question: https://stackoverflow.com/q/41730532/6574038 ? – jay.sf Jan 13 '21 at 09:57
  • 1
    Hey jay.sf! I'm using exactly same code they are using and as you can see in my question - it's not working in binary case. – John Jan 13 '21 at 10:11
  • Hi John, I was looking at r-caret questions and saw this. I think the linked question should have a working answer for you. – StupidWolf Jan 15 '21 at 07:22

0 Answers0