# \donttest{
data(colcancer)
colcancer80 <- colcancer[1:80, ]
# linear mode regression
regL <- modreg(Surv(logfollowup, death) ~ sex + age, data = colcancer80)
# bootstrap with a fixed bandwidth and 3 iterations, chosen to speed up the function.
# Should in practice be much more than 3 iterations.
btL <- boot.modreg(regL, 3, bw = "fixed", level = 0.9, seed = 100)
# coefficients, SE and confidence intervals
cbind(coef(regL), btL$confparams)
## confidence inverval for smooth effect / predictions
reg <- modreg(Surv(logfollowup, death) ~ sex + s(age, bs = "ps"), data = colcancer80,
control = modreg.control(tol_opt = 10^-2, tol_opt2 = 10^-2, tol = 10^-3))
ndat <- data.frame(sex = rep(colcancer80$sex[1], 200), age = seq(50, 90, length = 200))
# iterations should in practice be much more than 2!
bt <- boot.modreg(reg, 2, bw = "fixed", newdata = ndat, terms = "s(age)", seed = 100)
pr <- predict(reg, newdata = ndat, type = "terms", terms = "s(age)")[, 1]
plot(ndat$age, pr, ylim = c(-0.75, 1.5), type = "l", xlab = "age", ylab = "s(age)")
lines(ndat$age, bt$confpredict$lower, lty = 2)
lines(ndat$age, bt$confpredict$upper, lty = 2)
# }
Run the code above in your browser using DataLab