library(pminternal)
set.seed(456)
# simulate data with two predictors that interact
dat <- pmcalibration::sim_dat(N = 1000, a1 = -2, a3 = -.3)
mean(dat$y)
dat$LP <- NULL # remove linear predictor
# fit a (misspecified) logistic regression model
model_fun <- function(data, ...){
glm(y ~ x1 + x2, data=data, family="binomial")
}
pred_fun <- function(model, data, ...){
predict(model, newdata=data, type="response")
}
boot_optimism(data=dat, outcome="y", model_fun=model_fun, pred_fun=pred_fun,
method="boot", B=20) # B set to 20 for example but should be >= 200
Run the code above in your browser using DataLab