Reputation: 766
I would like to be able to generate a confidence interval from a model that I create with the package caret. This can be done using predict(model, data, interval = "confidence")
when the model is created with lm()
. However, when I try the same command with a model created with caret's train()
function, I get the following error:
Error in extractPrediction(list(object), unkX = newdata, unkOnly = TRUE, :
unused argument (interval = "confidence")
This is true even when I set method = "lm"
in the train
function. Does anyone know how to get a confidence interval from such an object? Preferably using predict
so the format is the same.
Thanks!
Upvotes: 7
Views: 4486
Reputation: 766
Found out how to do this! caret
objects do in fact store the original model, beneath a huge pile of metadata. You can access this model with my_model_name$finalModel
. Thus, to find the confidence interval, you would call predict(my_model_name$finalModel, my_data, interval = "confidence")
.
Upvotes: 6