#Determine a risk-adjustment model using a generalized linear model.
#Outcome (failure within 100 days) is regressed on the available covariates:
glmmodber <- glm((survtime <= 100) & (censorid == 1)~ age + sex + BMI,
data = surgerydat, family = binomial(link = "logit"))
#Determine the Average Run Length in number of outcomes for
#control limit h = 2.5 with (0, h) divided into n_grid = 200 segments
ARL <- bernoulli_ARL(h = 2.5, n_grid = 200, glmmod = glmmodber, theta = log(2))
#Calculate ARL, but now exploiting connection between SPRT and CUSUM:
#n_grid now decides the accuracy of the Trapezoidal rule for integral approximation
ARLSPRT <- bernoulli_ARL(h = 2.5, n_grid = 200, glmmod = glmmodber,
theta = log(2), method = "SPRT")
# \donttest{
#We can compare our ARL with that determined using the VLAD package
#See \url{https://cran.r-project.org/package=vlad}
if(require("vlad")){
fi <- as.numeric(table(glmmodber$fitted.values)/length(glmmodber$fitted.values))
pi1 <- sort(unique(glmmodber$fitted.values))
pmix1 <- data.frame(fi, pi1, pi1)
vlad_ARL <- round(vlad::racusum_arl_mc(pmix = pmix1, RA = 2, RQ = 1, h = 2.5, scaling = 200))
print(vlad_ARL)
}
# }
Run the code above in your browser using DataLab