## Exactly reproduce the example in Section 4.1 of Aslett et al (2015), including Figure 5
# First specify the system layout, numbered as per Figure 4
sys <- createSystem(s -- 1 -- 2:4:5, 2 -- 3 -- t, 4:5 -- 6 -- t,
s -- 7 -- 8 -- t, s -- 9 -- 10 -- 11 -- t, 7 -- 10 -- 8,
types = list(T1 = c(1, 6, 11),
T2 = c(2, 3, 9),
T3 = c(4, 5, 10),
T4 = c(7, 8)))
# Compute the survival signature table from Appendix
sig <- computeSystemSurvivalSignature(sys)
# Simulate the test data (same seed as used in the paper)
set.seed(233)
t1 <- rexp(100, rate=0.55)
t2 <- rweibull(100, scale=1.8, shape=2.2)
t3 <- rlnorm(100, 0.4, 0.9)
t4 <- rgamma(100, scale=0.9, shape=3.2)
# Compile into a list as required by this function
test.data <- list("T1"=t1, "T2"=t2, "T3"=t3, "T4"=t4)
# Create a vector of times at which to evaluate the posterior predictive
# survival probability and compute using this function
t <- seq(0, 5, length.out=300)
yS <- nonParBayesSystemInference(t, sig, test.data)
# Compute the survival curves for the individual components (just to match
# Figure 5)
y1 <- sapply(t, pexp, rate=0.55, lower.tail=FALSE)
y2 <- sapply(t, pweibull, scale=1.8, shape=2.2, lower.tail=FALSE)
y3 <- sapply(t, plnorm, meanlog=0.4, sdlog=0.9, lower.tail=FALSE)
y4 <- sapply(t, pgamma, scale=0.9, shape=3.2, lower.tail=FALSE)
# Plot
# \donttest{
library(ggplot2)
p <- ggplot(data.frame(Time=rep(t,5), Probability=c(yS,y1,y2,y3,y4),
Item=c(rep(c("System", "T1", "T2", "T3", "T4"), each=300))))
p <- p + geom_line(aes(x=Time, y=Probability, linetype=Item))
p <- p + xlab("Time") + ylab("Survival Probability")
p# }
Run the code above in your browser using DataLab