7

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!

1
  • Please read error messages and help pages. It's telling you there is no parameter to the extractPrediction-function named "interval". Since the inference model for resampling procedures is different than for the usual use of lm, you might want to adjust your expectations.
    – IRTFM
    Commented Jul 6, 2015 at 22:26

1 Answer 1

6

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").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.