I am working with the Titanic dataset and trying to use logistic regression in R to predict survival. The simple approach I tried was to just use the glm function with binomial family and logit link specified:
f = as.formula("Survived_char ~ Pclass_char+Sex+mAgeD+SibSp+Title+FsizeD")
logit <- glm(f, family=binomial(link="logit"), data=new_train)
The next approach was to use the train function in the caret package with cross validation:
tc <- trainControl(method = "repeatedcv", number=10, repeats = 5,
classProbs = TRUE, summaryFunction = twoClassSummary)
fit <- train(form=f,data=new_train,method="glm",
tuneLength=5, trControl=tc,metric="ROC",
family=binomial(link="logit"))
However, the two models have the same coefficients. Is that correct? I thought that k-fold cross validation would yield a model where the coefficients were averages of the k models developed. If the same model is generated with and without cross validation, what is the advantage of developing a model with the train function rather than using glm directly?