## Breast Cancer study (radiotherapy only group)
## Dirichlet process approach to estimate nonparametrically
## the survival distribution with interval-censored data
data("breastCancer", package = "icensBKL")
breastR <- subset(breastCancer, treat == "radio only", select = c("low", "upp"))
### Lower and upper interval limit to be used here
low <- breastR[, "low"]
upp <- breastR[, "upp"]
### Common parameters for sampling
### (quite low, only for testing)
n.sample <- 100
n.burn <- 100
### Gibbs sampler
set.seed(19680821)
Samp <- NPICbayesSurv(low, upp, choice = "weibull", n.sample = n.sample, n.burn = n.burn)
print(ncol(Samp$w)) ## number of supporting intervals
print(nrow(Samp$S)) ## number of grid points (without "infinity")
print(Samp$S[, "t"]) ## grid points (without "infinity")
print(Samp$t) ## grid points (without "infinity")
print(Samp$S) ## posterior mean and pointwise credible intervals
print(Samp$w[1:10,]) ## sampled weights (the first 10 iterations)
print(Samp$n[1:10,]) ## sampled latend vectors (the first 10 iterations)
print(Samp$Ssample[1:10,]) ## sampled S (the first 10 iterations)
print(Samp$parm) ## parameters of the guess
### Fitted survival function including pointwise credible bands
ngrid <- nrow(Samp$S)
plot(Samp$S[1:(ngrid-1), "t"], Samp$S[1:(ngrid-1), "Mean"], type = "l",
xlim = c(0, 50), ylim = c(0, 1), xlab = "Time", ylab = expression(hat(S)(t)))
polygon(c(Samp$S[1:(ngrid-1), "t"], Samp$S[(ngrid-1):1, "t"]),
c(Samp$S[1:(ngrid-1), "Lower"], Samp$S[(ngrid-1):1, "Upper"]),
col = "grey95", border = NA)
lines(Samp$S[1:(ngrid - 1), "t"], Samp$S[1:(ngrid - 1), "Lower"], col = "grey", lwd = 2)
lines(Samp$S[1:(ngrid - 1), "t"], Samp$S[1:(ngrid - 1), "Upper"], col = "grey", lwd = 2)
lines(Samp$S[1:(ngrid - 1), "t"], Samp$S[1:(ngrid - 1), "Mean"], col = "black", lwd = 3)
Run the code above in your browser using DataLab