set.seed(1)
sim_data <- simIC_weib(n = 500, b1 = .3, b2 = -.3,
shape = 2, scale = 2,
inspections = 6, inspectLength = 1)
fit <- ic_sp(Surv(l, u, type = 'interval2') ~ x1 + x2,
data = sim_data, bs_samples = 0)
new_data <- data.frame(x1 = c(0,1), x2 = c(1, 1) )
#want to fit survival curves with above covariates
rownames(new_data) <- c('group 1', 'group 2')
#getSCurves will name the survival curves according to rownames
curveInfo <- getSCurves(fit, new_data)
xs <- curveInfo$Tbull_ints
#Extracting Turnbull intervals
sCurves <- curveInfo$S_curves
#Extracting estimated survival curves
plot(xs[,1], sCurves[[1]], xlab = 'time', ylab = 'S(t)',
type = 's', ylim = c(0,1),
xlim = range(as.numeric(xs), finite = TRUE))
#plotting upper survival curve estimate
lines(xs[,2], sCurves[[1]], type = 's')
#plotting lower survival curve estimate
lines(xs[,1], sCurves[[2]], col = 'blue', type = 's')
lines(xs[,2], sCurves[[2]], col = 'blue', type = 's')
#plotting upper and lower survival curves for group 2
# Actually, all this plotting is a unnecessary:
# plot(fit, new_data) will bascially do this all
# But this is more of a tutorial in case custom
# plots were desired
Run the code above in your browser using DataLab