In R, I specify a model with no intercept as follows:
data(iris)
lmFit <- lm(Sepal.Length ~ 0 + Petal.Length + Petal.Width, data=iris)
> round(coef(lmFit),2)
Petal.Length Petal.Width
2.86 -4.48
However, if I fit the same model with caret, the resulting model includes an intercept:
library(caret)
caret_lmFit <- train(Sepal.Length~0+Petal.Length+Petal.Width, data=iris, "lm")
> round(coef(caret_lmFit$finalModel),2)
(Intercept) Petal.Length Petal.Width
4.19 0.54 -0.32
How do I tell caret::train
to exclude the intercept term?
createModel.R
line 25:modFormula <- as.formula(".outcome ~ .")
; the intercept is always included – Banda