How do I compute the bootstrap estimate for my regression coefficients using the function bootcov
from the package rms
? I tried the below with sample dataset but got an error:
library(mlbench)
data(PimaIndiansDiabetes)
library(caret)
trControl <- trainControl(method = "repeatedcv",
repeats = 3,
classProbs = TRUE,
number = 10,
savePredictions = TRUE,
summaryFunction = twoClassSummary)
caret_model <- train(diabetes~.,
data=PimaIndiansDiabetes,
method="glm",
trControl=trControl)
library(rms)
set.seed(1234)
reduced_model_bootcov <- bootcov(caret_model$finalModel, B=100)
The error is:
Error in bootcov(caret_model$finalModel, B = 100) : you did not specify x=TRUE and y=TRUE in the fit
If I use the function glm
to build the model, this is what I would do:
model <- glm(diabetes~.,
data=PimaIndiansDiabetes,
family=binomial,
x=TRUE, y=TRUE)
model_bootcov <- bootcov(model, B=100)
But again, I got a different error:
Error in bootcov(model, B = 100) : fitter not valid