Is there a way to generate a confidence interval from a caret lm object?

ⅰ亾dé卋堺 提交于 2019-12-07 01:53:59

问题


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:


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



来源:https://stackoverflow.com/questions/31255426/is-there-a-way-to-generate-a-confidence-interval-from-a-caret-lm-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!