1
$\begingroup$

When applying the lm function as follows (the assumptions were not considered. The purpose of this example is just to make my question clear) :

library(carData)

model1 = lm(data = carData::Salaries,salary~sex+yrs.service+yrs.since.phd)

and comparing it with the model created with the function caret::train() (method = "lm") :

library(caret)

mycontrol = trainControl(method = "CV",number=10,)

model2 = train(salary~sex+yrs.service+yrs.since.phd,
               data = Salaries,
               method = "lm",
               trControl=mycontrol)

The outcomes of the two models are the same. why ?

summary(model1)
summary(model2)
$\endgroup$
1
  • 1
    $\begingroup$ The answer to your question lies in the implementation of the caret package and what is shown to the user in the summary method. This is likely a question for the caret package maintainers. $\endgroup$
    – R Carnell
    Commented Sep 16, 2022 at 16:36

0

Browse other questions tagged or ask your own question.